updated to 1.14.3 pre 2, still issues with fabric spawn tracking mappings

This commit is contained in:
gnembon committed 2019-06-07 11:51:11 -03:00
1 parent a5d83a0c53
commit f3da8b2576
31 files changed
+180 -173

No files matched your search

+4 -4
View File
@@ -15,7 +15,7 @@ import net.minecraft.block.BlockPlacementEnvironment;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.text.BaseText;
import net.minecraft.world.World;
import java.util.ArrayList;
@@ -149,7 +149,7 @@ public class BlockInfo
put(Material.CAKE , "cake" );
}};
public static List<BaseComponent> blockInfo(BlockPos pos, World world)
public static List<BaseText> blockInfo(BlockPos pos, World world)
{
BlockState state = world.getBlockState(pos);
Material material = state.getMaterial();
@@ -159,7 +159,7 @@ public class BlockInfo
{
metastring += ", "+iproperty.getName() + '='+state.get(iproperty);
}
List<BaseComponent> lst = new ArrayList<>();
List<BaseText> lst = new ArrayList<>();
lst.add(Messenger.s(""));
lst.add(Messenger.s("====================================="));
lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):",Registry.BLOCK.getId(block),metastring, Registry.BLOCK.getRawId(block), metastring )));
@@ -198,7 +198,7 @@ public class BlockInfo
return lst;
}
private static BaseComponent wander_chances(BlockPos pos, World worldIn)
private static BaseText wander_chances(BlockPos pos, World worldIn)
{
MobEntityWithAi creature = new ZombiePigmanEntity(EntityType.ZOMBIE_PIGMAN, worldIn);
creature.initialize(worldIn, worldIn.getLocalDifficulty(pos), SpawnType.NATURAL, null, null);
@@ -3,7 +3,7 @@ package carpet.utils;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.text.BaseText;
import java.util.ArrayList;
import java.util.HashMap;
@@ -18,7 +18,7 @@ public class DistanceCalculator
return START_POINT_STORAGE.containsKey(source.getName());
}
public static List<BaseComponent> findDistanceBetweenTwoPoints(Vec3d pos1, Vec3d pos2)
public static List<BaseText> findDistanceBetweenTwoPoints(Vec3d pos1, Vec3d pos2)
{
double dx = MathHelper.abs((float)pos1.x-(float)pos2.x);
double dy = MathHelper.abs((float)pos1.y-(float)pos2.y);
@@ -26,7 +26,7 @@ public class DistanceCalculator
double manhattan = dx+dy+dz;
double spherical = MathHelper.sqrt(dx*dx + dy*dy + dz*dz);
double cylindrical = MathHelper.sqrt(dx*dx + dz*dz);
List<BaseComponent> res = new ArrayList<>();
List<BaseText> res = new ArrayList<>();
res.add(Messenger.c("w Distance between ",
Messenger.tp("c",pos1),"w and ",
Messenger.tp("c",pos2),"w :"));
+5 -5
View File
@@ -4,7 +4,7 @@ import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.text.BaseText;
import net.minecraft.world.World;
import java.util.ArrayList;
@@ -39,7 +39,7 @@ public class EntityInfo
{
return null;
} // func_190916_E()
String stackname = item.getCount()>1?String.format("%dx%s",item.getCount(), item.getCustomName().getString()):item.getCustomName().getString();
String stackname = item.getCount()>1?String.format("%dx%s",item.getCount(), item.getName().getString()):item.getName().getString();
if (item.isDamaged())
{
stackname += String.format(" %d/%d", item.getMaxUseTime()-item.getDamage(), item.getMaxUseTime());
@@ -51,7 +51,7 @@ public class EntityInfo
for (Enchantment e: enchants.keySet())
{
int level = enchants.get(e);
String enstring = e.getTextComponent(level).getString();
String enstring = e.getName(level).getString();
stackname += enstring+" ";
}
stackname += ")";
@@ -92,9 +92,9 @@ public class EntityInfo
return 100*(internal-min)/(max-min);
}
public static List<BaseComponent> entityInfo(Entity e, World source_world)
public static List<BaseText> entityInfo(Entity e, World source_world)
{
List<BaseComponent> lst = new ArrayList<>();
List<BaseText> lst = new ArrayList<>();
lst.add(Messenger.s("w Use /data get entity command"));
return lst;
}
+16 -16
View File
@@ -12,8 +12,8 @@ import net.minecraft.client.network.packet.PlayerListHeaderS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Pair;
import net.minecraft.util.math.MathHelper;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.text.BaseText;
import net.minecraft.text.LiteralText;
import net.minecraft.world.dimension.DimensionType;
import java.util.ArrayList;
@@ -25,9 +25,9 @@ import java.util.Map;
public class HUDController
{
public static Map<PlayerEntity, List<BaseComponent>> player_huds = new HashMap<>();
public static Map<PlayerEntity, List<BaseText>> player_huds = new HashMap<>();
public static void addMessage(PlayerEntity player, BaseComponent hudMessage)
public static void addMessage(PlayerEntity player, BaseText hudMessage)
{
if (!player_huds.containsKey(player))
{
@@ -35,15 +35,15 @@ public class HUDController
}
else
{
player_huds.get(player).add(new TextComponent("\n"));
player_huds.get(player).add(new LiteralText("\n"));
}
player_huds.get(player).add(hudMessage);
}
public static void clear_player(PlayerEntity player)
{
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new TextComponent(""));
((PlayerListHeaderS2CPacketMixin)packet).setFooter(new TextComponent(""));
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText(""));
((PlayerListHeaderS2CPacketMixin)packet).setFooter(new LiteralText(""));
((ServerPlayerEntity)player).networkHandler.sendPacket(packet);
}
@@ -73,7 +73,7 @@ public class HUDController
dim = DimensionType.THE_END;
break;
}
return new BaseComponent[]{SpawnReporter.printMobcapsForDimension(dim, false).get(0)};
return new BaseText[]{SpawnReporter.printMobcapsForDimension(dim, false).get(0)};
});
if(LoggerRegistry.__counter)
@@ -85,30 +85,30 @@ public class HUDController
for (PlayerEntity player: player_huds.keySet())
{
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new TextComponent(""));
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText(""));
((PlayerListHeaderS2CPacketMixin)packet).setFooter(Messenger.c(player_huds.get(player).toArray(new Object[0])));
((ServerPlayerEntity)player).networkHandler.sendPacket(packet);
}
}
private static BaseComponent [] send_tps_display(MinecraftServer server)
private static BaseText [] send_tps_display(MinecraftServer server)
{
double MSPT = MathHelper.average(server.lastTickLengths) * 1.0E-6D;
double TPS = 1000.0D / Math.max((TickSpeed.time_warp_start_time != 0)?0.0:TickSpeed.mspt, MSPT);
String color = Messenger.heatmap_color(MSPT,TickSpeed.mspt);
return new BaseComponent[]{Messenger.c(
return new BaseText[]{Messenger.c(
"g TPS: ", String.format(Locale.US, "%s %.1f",color, TPS),
"g MSPT: ", String.format(Locale.US,"%s %.1f", color, MSPT))};
}
private static BaseComponent [] send_counter_info(MinecraftServer server, String color)
private static BaseText [] send_counter_info(MinecraftServer server, String color)
{
HopperCounter counter = HopperCounter.getCounter(color);
List <BaseComponent> res = counter == null ? Collections.emptyList() : counter.format(server, false, true);
return new BaseComponent[]{ Messenger.c(res.toArray(new Object[0]))};
List <BaseText> res = counter == null ? Collections.emptyList() : counter.format(server, false, true);
return new BaseText[]{ Messenger.c(res.toArray(new Object[0]))};
}
private static BaseComponent [] packetCounter()
private static BaseText [] packetCounter()
{
BaseComponent [] ret = new BaseComponent[]{
BaseText [] ret = new BaseText[]{
Messenger.c("w I/" + PacketCounter.totalIn + " O/" + PacketCounter.totalOut),
};
PacketCounter.reset();
+51 -51
View File
@@ -5,12 +5,12 @@ import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.ChatFormat;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.text.BaseText;
import net.minecraft.server.MinecraftServer;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.HoverEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -51,7 +51,7 @@ public class Messenger
/ = action added to the previous component
*/
private static BaseComponent _applyStyleToTextComponent(BaseComponent comp, String style)
private static BaseText _applyStyleToTextComponent(BaseText comp, String style)
{
//could be rewritten to be more efficient
comp.getStyle().setItalic(style.indexOf('i')>=0);
@@ -59,23 +59,23 @@ public class Messenger
comp.getStyle().setUnderline(style.indexOf('u')>=0);
comp.getStyle().setBold(style.indexOf('b')>=0);
comp.getStyle().setObfuscated(style.indexOf('o')>=0);
comp.getStyle().setColor(ChatFormat.WHITE);
if (style.indexOf('w')>=0) comp.getStyle().setColor(ChatFormat.WHITE); // not needed
if (style.indexOf('y')>=0) comp.getStyle().setColor(ChatFormat.YELLOW);
if (style.indexOf('m')>=0) comp.getStyle().setColor(ChatFormat.LIGHT_PURPLE);
if (style.indexOf('r')>=0) comp.getStyle().setColor(ChatFormat.RED);
if (style.indexOf('c')>=0) comp.getStyle().setColor(ChatFormat.AQUA);
if (style.indexOf('l')>=0) comp.getStyle().setColor(ChatFormat.GREEN);
if (style.indexOf('t')>=0) comp.getStyle().setColor(ChatFormat.BLUE);
if (style.indexOf('f')>=0) comp.getStyle().setColor(ChatFormat.DARK_GRAY);
if (style.indexOf('g')>=0) comp.getStyle().setColor(ChatFormat.GRAY);
if (style.indexOf('d')>=0) comp.getStyle().setColor(ChatFormat.GOLD);
if (style.indexOf('p')>=0) comp.getStyle().setColor(ChatFormat.DARK_PURPLE);
if (style.indexOf('n')>=0) comp.getStyle().setColor(ChatFormat.DARK_RED);
if (style.indexOf('q')>=0) comp.getStyle().setColor(ChatFormat.DARK_AQUA);
if (style.indexOf('e')>=0) comp.getStyle().setColor(ChatFormat.DARK_GREEN);
if (style.indexOf('v')>=0) comp.getStyle().setColor(ChatFormat.DARK_BLUE);
if (style.indexOf('k')>=0) comp.getStyle().setColor(ChatFormat.BLACK);
comp.getStyle().setColor(Formatting.WHITE);
if (style.indexOf('w')>=0) comp.getStyle().setColor(Formatting.WHITE); // not needed
if (style.indexOf('y')>=0) comp.getStyle().setColor(Formatting.YELLOW);
if (style.indexOf('m')>=0) comp.getStyle().setColor(Formatting.LIGHT_PURPLE);
if (style.indexOf('r')>=0) comp.getStyle().setColor(Formatting.RED);
if (style.indexOf('c')>=0) comp.getStyle().setColor(Formatting.AQUA);
if (style.indexOf('l')>=0) comp.getStyle().setColor(Formatting.GREEN);
if (style.indexOf('t')>=0) comp.getStyle().setColor(Formatting.BLUE);
if (style.indexOf('f')>=0) comp.getStyle().setColor(Formatting.DARK_GRAY);
if (style.indexOf('g')>=0) comp.getStyle().setColor(Formatting.GRAY);
if (style.indexOf('d')>=0) comp.getStyle().setColor(Formatting.GOLD);
if (style.indexOf('p')>=0) comp.getStyle().setColor(Formatting.DARK_PURPLE);
if (style.indexOf('n')>=0) comp.getStyle().setColor(Formatting.DARK_RED);
if (style.indexOf('q')>=0) comp.getStyle().setColor(Formatting.DARK_AQUA);
if (style.indexOf('e')>=0) comp.getStyle().setColor(Formatting.DARK_GREEN);
if (style.indexOf('v')>=0) comp.getStyle().setColor(Formatting.DARK_BLUE);
if (style.indexOf('k')>=0) comp.getStyle().setColor(Formatting.BLACK);
return comp;
}
public static String heatmap_color(double actual, double reference)
@@ -103,11 +103,11 @@ public class Messenger
return "w";
}
private static BaseComponent _getChatComponentFromDesc(String message, BaseComponent previous_message)
private static BaseText _getChatComponentFromDesc(String message, BaseText previous_message)
{
if (message.equalsIgnoreCase(""))
{
return new TextComponent("");
return new LiteralText("");
}
String parts[] = message.split("\\s", 2);
String desc = parts[0];
@@ -137,27 +137,27 @@ public class Messenger
previous_message.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c(message.substring(1))));
return previous_message;
}
BaseComponent txt = new TextComponent(str);
BaseText txt = new LiteralText(str);
return _applyStyleToTextComponent(txt, desc);
}
public static BaseComponent tp(String desc, Vec3d pos) { return tp(desc, pos.x, pos.y, pos.z); }
public static BaseComponent tp(String desc, BlockPos pos) { return tp(desc, pos.getX(), pos.getY(), pos.getZ()); }
public static BaseComponent tp(String desc, double x, double y, double z) { return tp(desc, (float)x, (float)y, (float)z);}
public static BaseComponent tp(String desc, float x, float y, float z)
public static BaseText tp(String desc, Vec3d pos) { return tp(desc, pos.x, pos.y, pos.z); }
public static BaseText tp(String desc, BlockPos pos) { return tp(desc, pos.getX(), pos.getY(), pos.getZ()); }
public static BaseText tp(String desc, double x, double y, double z) { return tp(desc, (float)x, (float)y, (float)z);}
public static BaseText tp(String desc, float x, float y, float z)
{
return _getCoordsTextComponent(desc, x, y, z, false);
}
public static BaseComponent tp(String desc, int x, int y, int z)
public static BaseText tp(String desc, int x, int y, int z)
{
return _getCoordsTextComponent(desc, (float)x, (float)y, (float)z, true);
}
/// to be continued
public static BaseComponent dbl(String style, double double_value)
public static BaseText dbl(String style, double double_value)
{
return c(String.format("%s %.1f",style,double_value),String.format("^w %f",double_value));
}
public static BaseComponent dbls(String style, double ... doubles)
public static BaseText dbls(String style, double ... doubles)
{
StringBuilder str = new StringBuilder(style + " [ ");
String prefix = "";
@@ -169,7 +169,7 @@ public class Messenger
str.append(" ]");
return c(str.toString());
}
public static BaseComponent dblf(String style, double ... doubles)
public static BaseText dblf(String style, double ... doubles)
{
StringBuilder str = new StringBuilder(style + " [ ");
String prefix = "";
@@ -181,7 +181,7 @@ public class Messenger
str.append(" ]");
return c(str.toString());
}
public static BaseComponent dblt(String style, double ... doubles)
public static BaseText dblt(String style, double ... doubles)
{
List<Object> components = new ArrayList<>();
components.add(style+" [ ");
@@ -199,7 +199,7 @@ public class Messenger
return c(components.toArray(new Object[0]));
}
private static BaseComponent _getCoordsTextComponent(String style, float x, float y, float z, boolean isInt)
private static BaseText _getCoordsTextComponent(String style, float x, float y, float z, boolean isInt)
{
String text;
String command;
@@ -229,20 +229,20 @@ public class Messenger
/*
composes single line, multicomponent message, and returns as one chat messagge
*/
public static BaseComponent c(Object ... fields)
public static BaseText c(Object ... fields)
{
BaseComponent message = new TextComponent("");
BaseComponent previous_component = null;
BaseText message = new LiteralText("");
BaseText previous_component = null;
for (Object o: fields)
{
if (o instanceof BaseComponent)
if (o instanceof BaseText)
{
message.append((BaseComponent)o);
previous_component = (BaseComponent)o;
message.append((BaseText)o);
previous_component = (BaseText)o;
continue;
}
String txt = o.toString();
BaseComponent comp = _getChatComponentFromDesc(txt,previous_component);
BaseText comp = _getChatComponentFromDesc(txt,previous_component);
if (comp != previous_component) message.append(comp);
previous_component = comp;
}
@@ -251,13 +251,13 @@ public class Messenger
//simple text
public static BaseComponent s(String text)
public static BaseText s(String text)
{
return s(text,"");
}
public static BaseComponent s(String text, String style)
public static BaseText s(String text, String style)
{
BaseComponent message = new TextComponent(text);
BaseText message = new LiteralText(text);
_applyStyleToTextComponent(message, style);
return message;
}
@@ -265,11 +265,11 @@ public class Messenger
public static void send(PlayerEntity player, Collection<BaseComponent> lines)
public static void send(PlayerEntity player, Collection<BaseText> lines)
{
lines.forEach(player::sendMessage);
}
public static void send(ServerCommandSource source, Collection<BaseComponent> lines)
public static void send(ServerCommandSource source, Collection<BaseText> lines)
{
lines.stream().forEachOrdered((s) -> source.sendFeedback(s, false));
}
@@ -279,14 +279,14 @@ public class Messenger
{
if (server == null)
LOG.error("Message not delivered: "+message);
server.sendMessage(new TextComponent(message));
BaseComponent txt = c("gi "+message);
server.sendMessage(new LiteralText(message));
BaseText txt = c("gi "+message);
for (PlayerEntity entityplayer : server.getPlayerManager().getPlayerList())
{
entityplayer.sendMessage(txt);
}
}
public static void print_server_message(MinecraftServer server, BaseComponent message)
public static void print_server_message(MinecraftServer server, BaseText message)
{
if (server == null)
LOG.error("Message not delivered: "+message.getString());
+12 -12
View File
@@ -14,7 +14,7 @@ import net.minecraft.entity.SpawnRestriction;
import net.minecraft.entity.SpawnType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.OcelotEntity;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.text.BaseText;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
@@ -84,10 +84,10 @@ public class SpawnReporter
}
public static List<BaseComponent> printMobcapsForDimension(DimensionType dim, boolean multiline)
public static List<BaseText> printMobcapsForDimension(DimensionType dim, boolean multiline)
{
String name = dim.toString();
List<BaseComponent> lst = new ArrayList<>();
List<BaseText> lst = new ArrayList<>();
if (multiline)
lst.add(Messenger.s(String.format("Mobcaps for %s:",name)));
Object2IntMap<EntityCategory> dimCounts = mobCounts.get(dim);
@@ -137,9 +137,9 @@ public class SpawnReporter
return lst;
}
public static List<BaseComponent> recent_spawns(World world, EntityCategory creature_type)
public static List<BaseText> recent_spawns(World world, EntityCategory creature_type)
{
List<BaseComponent> lst = new ArrayList<>();
List<BaseText> lst = new ArrayList<>();
if ((track_spawns == 0L))
{
lst.add(Messenger.s("Spawn tracking not started"));
@@ -165,7 +165,7 @@ public class SpawnReporter
}
public static List<BaseComponent> show_mobcaps(BlockPos pos, World worldIn)
public static List<BaseText> show_mobcaps(BlockPos pos, World worldIn)
{
DyeColor under = WoolTool.getWoolColorAtPosition(worldIn, pos.down());
if (under == null)
@@ -254,9 +254,9 @@ public class SpawnReporter
return get_type_string(get_creature_type_from_code(str));
}
public static List<BaseComponent> printEntitiesByType(EntityCategory cat, World worldIn) //Class<?> entityType)
public static List<BaseText> printEntitiesByType(EntityCategory cat, World worldIn) //Class<?> entityType)
{
List<BaseComponent> lst = new ArrayList<>();
List<BaseText> lst = new ArrayList<>();
lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat))));
for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getCategory()==cat))
{
@@ -318,10 +318,10 @@ public class SpawnReporter
track_spawns = 0L;
}
public static List<BaseComponent> tracking_report(World worldIn)
public static List<BaseText> tracking_report(World worldIn)
{
List<BaseComponent> report = new ArrayList<>();
List<BaseText> report = new ArrayList<>();
if (track_spawns == 0L)
{
report.add(Messenger.c(
@@ -395,9 +395,9 @@ public class SpawnReporter
entity.remove();
}
public static List<BaseComponent> report(BlockPos pos, World worldIn)
public static List<BaseText> report(BlockPos pos, World worldIn)
{
List<BaseComponent> rep = new ArrayList<>();
List<BaseText> rep = new ArrayList<>();
int x = pos.getX(); int y = pos.getY(); int z = pos.getZ();
Chunk chunk = worldIn.getChunk(pos);
int lc = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, x, z) + 1;
+2 -2
View File
@@ -10,7 +10,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.text.BaseText;
import net.minecraft.world.World;
import java.util.ArrayList;
@@ -84,7 +84,7 @@ public class WoolTool
HopperCounter counter = HopperCounter.getCounter(under.toString());
if (counter == null) return;
counter.reset(placer.getServer());
List<BaseComponent> res = new ArrayList<>();
List<BaseText> res = new ArrayList<>();
res.add(Messenger.s(String.format("%s counter reset",under.toString())));
Messenger.send(placer, res);
}