Update to 1.14.2

This commit is contained in:
LexManos authored and cpw committed 2019-06-07 16:50:47 -04:00
1 parent d3e8804dbf
commit a7df63e1a1
1010 files changed
+15254 -19520

No files matched your search

@@ -24,13 +24,13 @@ import java.util.ArrayDeque;
import java.util.Queue;
import net.minecraft.command.CommandSource;
import net.minecraft.server.management.PlayerChunkMapEntry;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentBase;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.WorldServer;
import net.minecraft.util.text.TextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.storage.SessionLockException;
import net.minecraftforge.common.DimensionManager;
@@ -86,9 +86,9 @@ public class ChunkGenWorker implements IWorker
return ret;
}
public TextComponentBase getStartMessage(CommandSource sender)
public TextComponent getStartMessage(CommandSource sender)
{
return new TextComponentTranslation("commands.forge.gen.start", total, start.getX(), start.getZ(), dim);
return new TranslationTextComponent("commands.forge.gen.start", total, start.getX(), start.getZ(), dim);
}
@Override
@@ -100,29 +100,31 @@ public class ChunkGenWorker implements IWorker
@Override
public boolean doWork()
{
WorldServer world = DimensionManager.getWorld(listener.getServer(), dim, false, false);
ServerWorld world = DimensionManager.getWorld(listener.getServer(), dim, false, false);
if (world == null)
{
world = DimensionManager.initWorld(listener.getServer(), dim);
if (world == null)
{
listener.sendFeedback(new TextComponentTranslation("commands.forge.gen.dim_fail", dim), true);
listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.dim_fail", dim), true);
queue.clear();
return false;
}
}
/* TODO: Check how many things are pending save, and slow down world gen if to many
AnvilChunkLoader loader = world.getChunkProvider().chunkLoader instanceof AnvilChunkLoader ? (AnvilChunkLoader)world.getChunkProvider().chunkLoader : null;
if (loader != null && loader.getPendingSaveCount() > 100)
{
if (lastNotifcationTime < System.currentTimeMillis() - 10*1000)
{
listener.sendFeedback(new TextComponentTranslation("commands.forge.gen.progress", total - queue.size(), total), true);
listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true);
lastNotifcationTime = System.currentTimeMillis();
}
return false;
}
*/
BlockPos next = queue.poll();
@@ -136,7 +138,7 @@ public class ChunkGenWorker implements IWorker
if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60*1000)
{
listener.sendFeedback(new TextComponentTranslation("commands.forge.gen.progress", total - queue.size(), total), true);
listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true);
lastNotification = 0;
lastNotifcationTime = System.currentTimeMillis();
}
@@ -144,42 +146,17 @@ public class ChunkGenWorker implements IWorker
int x = next.getX();
int z = next.getZ();
Chunk target = world.getChunk(x, z);
Chunk[] chunks = { target };
if (!target.isPopulated())
{
// In order for a chunk to populate, The chunks around its bottom right corner need to be loaded.
// So lets load those chunks, but this needs to be done in a certain order to make this trigger.
// So this does load more chunks then it should, and is a hack, but lets go!.
chunks = new Chunk[] {
target,
world.getChunk(x + 1, z),
world.getChunk(x + 1, z + 1),
world.getChunk(x, z + 1),
};
try
{
world.getChunkProvider().chunkLoader.saveChunk(world, target);
}
catch (IOException | SessionLockException e)
{
listener.sendFeedback(new TextComponentTranslation("commands.forge.gen.saveerror", e.getMessage()), true);
}
genned++;
}
for (Chunk chunk : chunks) //Now lets unload them. Note: Saving is done off thread so there may be cache hits, but this should still unload everything.
{
PlayerChunkMapEntry watchers = world.getPlayerChunkMap().getEntry(chunk.x, chunk.z);
if (watchers == null) //If there are no players watching this, this will be null, so we can unload.
world.getChunkProvider().queueUnload(chunk);
}
IChunk chunk = world.func_217353_a(x, z, ChunkStatus.field_222617_m, false);
/* TODO: Mark things to unload
PlayerChunkMapEntry watchers = world.getPlayerChunkMap().getEntry(chunk.x, chunk.z);
if (watchers == null) //If there are no players watching this, this will be null, so we can unload.
world.getChunkProvider().queueUnload(chunk);
*/
}
if (queue.size() == 0)
{
listener.sendFeedback(new TextComponentTranslation("commands.forge.gen.complete", genned, total, dim), true);
listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.complete", genned, total, dim), true);
if (keepingLoaded != null && !keepingLoaded)
{
DimensionManager.keepLoaded(dim, false);
@@ -21,8 +21,8 @@ package net.minecraftforge.server.command;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.dimension.DimensionType;
import java.util.ArrayList;
import java.util.HashMap;
@@ -39,15 +39,15 @@ public class CommandDimensions
return Commands.literal("dimensions")
.requires(cs->cs.hasPermissionLevel(0)) //permission
.executes(ctx -> {
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.dimensions.list"), true);
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.dimensions.list"), true);
Map<String, List<String>> types = new HashMap<>();
for (DimensionType dim : DimensionType.func_212681_b()) {
for (DimensionType dim : DimensionType.getAll()) {
String key = dim.getModType() == null ? "Vanilla" : dim.getModType().getRegistryName().toString();
types.computeIfAbsent(key, k -> new ArrayList<>()).add(DimensionType.func_212678_a(dim).toString());
types.computeIfAbsent(key, k -> new ArrayList<>()).add(DimensionType.getKey(dim).toString());
}
types.keySet().stream().sorted().forEach(key -> {
ctx.getSource().sendFeedback(new TextComponentString(key + ": " + types.get(key).stream().sorted().collect(Collectors.joining(", "))), true);
ctx.getSource().sendFeedback(new StringTextComponent(key + ": " + types.get(key).stream().sorted().collect(Collectors.joining(", "))), true);
});
return 0;
});
@@ -40,9 +40,9 @@ import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.WorldServer;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.registries.ForgeRegistries;
@@ -60,16 +60,16 @@ class CommandEntity
private static class EntityListCommand
{
private static final SimpleCommandExceptionType INVALID_FILTER = new SimpleCommandExceptionType(new TextComponentTranslation("commands.forge.entity.list.invalid"));
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TextComponentTranslation("commands.forge.entity.list.invalidworld", dim));
private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TextComponentTranslation("commands.forge.entity.list.none"));
private static final SimpleCommandExceptionType INVALID_FILTER = new SimpleCommandExceptionType(new TranslationTextComponent("commands.forge.entity.list.invalid"));
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TranslationTextComponent("commands.forge.entity.list.invalidworld", dim));
private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TranslationTextComponent("commands.forge.entity.list.none"));
static ArgumentBuilder<CommandSource, ?> register()
{
return Commands.literal("list")
.requires(cs->cs.hasPermissionLevel(2)) //permission
.then(Commands.argument("filter", StringArgumentType.string())
.suggests((ctx, builder) -> ISuggestionProvider.suggest(ForgeRegistries.ENTITIES.getKeys().stream().map(id -> id.toString()), builder))
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
.then(Commands.argument("dim", DimensionArgument.getDimension())
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.func_212592_a(ctx, "dim")))
)
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), ctx.getSource().getWorld().dimension.getType()))
@@ -86,13 +86,12 @@ class CommandEntity
if (names.isEmpty())
throw INVALID_FILTER.create();
WorldServer world = DimensionManager.getWorld(sender.getServer(), dim, false, false);
ServerWorld world = DimensionManager.getWorld(sender.getServer(), dim, false, false);
if (world == null)
throw INVALID_DIMENSION.create(dim);
Map<ResourceLocation, MutablePair<Integer, Map<ChunkPos, Integer>>> list = Maps.newHashMap();
List<Entity> entities = world.loadedEntityList;
entities.forEach(e -> {
world.getEntities().forEach(e -> {
MutablePair<Integer, Map<ChunkPos, Integer>> info = list.computeIfAbsent(e.getType().getRegistryName(), k -> MutablePair.of(0, Maps.newHashMap()));
ChunkPos chunk = new ChunkPos(e.getPosition());
info.left++;
@@ -106,7 +105,7 @@ class CommandEntity
if (info == null)
throw NO_ENTITIES.create();
sender.sendFeedback(new TextComponentTranslation("commands.forge.entity.list.single.header", name, info.getLeft()), true);
sender.sendFeedback(new TranslationTextComponent("commands.forge.entity.list.single.header", name, info.getLeft()), true);
List<Map.Entry<ChunkPos, Integer>> toSort = new ArrayList<>();
toSort.addAll(info.getRight().entrySet());
toSort.sort((a, b) -> {
@@ -120,7 +119,7 @@ class CommandEntity
for (Map.Entry<ChunkPos, Integer> e : toSort)
{
if (limit-- == 0) break;
sender.sendFeedback(new TextComponentString(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z), true);
sender.sendFeedback(new StringTextComponent(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z), true);
}
return toSort.size();
}
@@ -146,8 +145,8 @@ class CommandEntity
throw NO_ENTITIES.create();
int count = info.stream().mapToInt(Pair::getRight).sum();
sender.sendFeedback(new TextComponentTranslation("commands.forge.entity.list.multiple.header", count), true);
info.forEach(e -> sender.sendFeedback(new TextComponentString(" " + e.getValue() + ": " + e.getKey()), true));
sender.sendFeedback(new TranslationTextComponent("commands.forge.entity.list.multiple.header", count), true);
info.forEach(e -> sender.sendFeedback(new StringTextComponent(" " + e.getValue() + ": " + e.getKey()), true));
return info.size();
}
}
@@ -19,30 +19,17 @@
package net.minecraftforge.server.command;
import javax.annotation.Nullable;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import net.minecraft.command.CommandException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.ISuggestionProvider;
import net.minecraft.command.arguments.BlockPosArgument;
import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.WorldWorkerManager;
class CommandGenerate
@@ -53,7 +40,7 @@ class CommandGenerate
.requires(cs->cs.hasPermissionLevel(4)) //permission
.then(Commands.argument("pos", BlockPosArgument.blockPos())
.then(Commands.argument("count", IntegerArgumentType.integer(1))
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
.then(Commands.argument("dim", DimensionArgument.getDimension())
.then(Commands.argument("interval", IntegerArgumentType.integer())
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.func_212592_a(ctx, "dim"), getInt(ctx, "interval")))
)
@@ -22,7 +22,7 @@ package net.minecraftforge.server.command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
@@ -34,7 +34,7 @@ public class CommandModList {
return Commands.literal("mods")
.requires(cs->cs.hasPermissionLevel(0)) //permission
.executes(ctx -> {
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.mods.list",
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.mods.list",
ModList.get().getMods().stream().map(ModInfo::getModId).collect(Collectors.joining(","))),
true);
return 0;
@@ -26,10 +26,9 @@ import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.util.ITeleporter;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
@@ -41,14 +40,14 @@ import java.util.function.Predicate;
public class CommandSetDimension
{
private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TextComponentTranslation("commands.forge.setdim.invalid.entity"));
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TextComponentTranslation("commands.forge.setdim.invalid.dim", dim));
private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TranslationTextComponent("commands.forge.setdim.invalid.entity"));
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TranslationTextComponent("commands.forge.setdim.invalid.dim", dim));
static ArgumentBuilder<CommandSource, ?> register()
{
return Commands.literal("setdimension")
.requires(cs->cs.hasPermissionLevel(2)) //permission
.then(Commands.argument("targets", EntityArgument.multipleEntities())
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
.then(Commands.argument("targets", EntityArgument.entities())
.then(Commands.argument("dim", DimensionArgument.getDimension())
.then(Commands.argument("pos", BlockPosArgument.blockPos())
.executes(ctx -> execute(ctx.getSource(), EntityArgument.getEntitiesAllowingNone(ctx, "targets"), DimensionArgument.func_212592_a(ctx, "dim"), BlockPosArgument.getBlockPos(ctx, "pos")))
)
@@ -66,9 +65,8 @@ public class CommandSetDimension
//if (!DimensionManager.isDimensionRegistered(dim))
// throw INVALID_DIMENSION.create(dim);
final ITeleporter teleporter = new CommandTeleporter(pos);
entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TextComponentTranslation("commands.forge.setdim.invalid.nochange", e.getDisplayName(), dim), true));
entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, teleporter));
entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName(), dim), true));
entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim));
return 0;
}
@@ -78,20 +76,4 @@ public class CommandSetDimension
// use vanilla portal logic from BlockPortal#onEntityCollision
return !entity.isPassenger() && !entity.isBeingRidden() && entity.isNonBoss();
}
private static class CommandTeleporter implements ITeleporter
{
private final BlockPos targetPos;
private CommandTeleporter(BlockPos targetPos)
{
this.targetPos = targetPos;
}
@Override
public void placeEntity(World world, Entity entity, float yaw)
{
entity.moveToBlockPosAndAngles(targetPos, yaw, entity.rotationPitch);
}
}
}
@@ -29,28 +29,28 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.dimension.DimensionType;
class CommandTps
{
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TextComponentTranslation("commands.forge.tps.invalid", dim, StreamSupport.stream(DimensionType.func_212681_b().spliterator(), false).map(d -> DimensionType.func_212678_a(d).toString()).sorted().collect(Collectors.joining(", "))));
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TranslationTextComponent("commands.forge.tps.invalid", dim, StreamSupport.stream(DimensionType.getAll().spliterator(), false).map(d -> DimensionType.getKey(d).toString()).sorted().collect(Collectors.joining(", "))));
private static final DecimalFormat TIME_FORMATTER = new DecimalFormat("########0.000");
static ArgumentBuilder<CommandSource, ?> register()
{
return Commands.literal("tps")
.requires(cs->cs.hasPermissionLevel(0)) //permission
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
.then(Commands.argument("dim", DimensionArgument.getDimension())
.executes(ctx -> sendTime(ctx.getSource(), DimensionArgument.func_212592_a(ctx, "dim")))
)
.executes(ctx -> {
for (DimensionType dim : DimensionType.func_212681_b())
for (DimensionType dim : DimensionType.getAll())
sendTime(ctx.getSource(), dim);
double meanTickTime = mean(ctx.getSource().getServer().tickTimeArray) * 1.0E-6D;
double meanTPS = Math.min(1000.0/meanTickTime, 20);
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), true);
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), true);
return 0;
}
@@ -62,11 +62,11 @@ class CommandTps
long[] times = cs.getServer().getTickTime(dim);
if (times == null)
throw INVALID_DIMENSION.create(DimensionType.func_212678_a(dim));
throw INVALID_DIMENSION.create(DimensionType.getKey(dim));
double worldTickTime = mean(times) * 1.0E-6D;
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
cs.sendFeedback(new TextComponentTranslation("commands.forge.tps.summary.named", dim.getId(), DimensionType.func_212678_a(dim), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), true);
cs.sendFeedback(new TranslationTextComponent("commands.forge.tps.summary.named", dim.getId(), DimensionType.getKey(dim), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), true);
return 1;
}
@@ -19,17 +19,10 @@
package net.minecraftforge.server.command;
import javax.annotation.Nullable;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -38,18 +31,12 @@ import java.util.function.Function;
import net.minecraft.command.CommandException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.ISuggestionProvider;
import net.minecraft.entity.Entity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.server.timings.ForgeTimings;
import net.minecraftforge.server.timings.TimeTracker;
@@ -79,7 +66,7 @@ class CommandTrack
int duration = IntegerArgumentType.getInteger(ctx, "duration");
TimeTracker.TILE_ENTITY_UPDATE.reset();
TimeTracker.TILE_ENTITY_UPDATE.enable(duration);
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.tracking.te.enabled", duration), true);
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.te.enabled", duration), true);
return 0;
})
)
@@ -90,7 +77,7 @@ class CommandTrack
int duration = IntegerArgumentType.getInteger(ctx, "duration");
TimeTracker.ENTITY_UPDATE.reset();
TimeTracker.ENTITY_UPDATE.enable(duration);
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.tracking.entity.enabled", duration), true);
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.entity.enabled", duration), true);
return 0;
})
)
@@ -107,14 +94,14 @@ class CommandTrack
.then(Commands.literal("te")
.executes(ctx -> {
TimeTracker.TILE_ENTITY_UPDATE.reset();
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.tracking.te.reset"), true);
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.te.reset"), true);
return 0;
})
)
.then(Commands.literal("entity")
.executes(ctx -> {
TimeTracker.ENTITY_UPDATE.reset();
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.tracking.entity.reset"), true);
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.entity.reset"), true);
return 0;
})
);
@@ -144,7 +131,7 @@ class CommandTrack
List<ForgeTimings<T>> timingsList = getSortedTimings(tracker);
if (timingsList.isEmpty())
{
source.sendFeedback(new TextComponentTranslation("commands.forge.tracking.no_data"), true);
source.sendFeedback(new TranslationTextComponent("commands.forge.tracking.no_data"), true);
}
else
{
@@ -165,13 +152,13 @@ class CommandTrack
{
Entity entity = data.getObject().get();
if (entity == null)
return new TextComponentTranslation("commands.forge.tracking.invalid");
return new TranslationTextComponent("commands.forge.tracking.invalid");
BlockPos pos = entity.getPosition();
double averageTimings = data.getAverageTimings();
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "�s" : "ms");
return new TextComponentTranslation("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), DimensionType.func_212678_a(entity.world.dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
return new TranslationTextComponent("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), DimensionType.getKey(entity.world.dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
})
);
}
@@ -185,13 +172,13 @@ class CommandTrack
{
TileEntity te = data.getObject().get();
if (te == null)
return new TextComponentTranslation("commands.forge.tracking.invalid");
return new TranslationTextComponent("commands.forge.tracking.invalid");
BlockPos pos = te.getPos();
double averageTimings = data.getAverageTimings();
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "�s" : "ms");
return new TextComponentTranslation("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), DimensionType.func_212678_a(te.getWorld().dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
return new TranslationTextComponent("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), DimensionType.getKey(te.getWorld().dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
})
);
}
@@ -20,11 +20,11 @@
package net.minecraftforge.server.command;
import net.minecraft.command.ICommandSource;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.util.text.TextComponentBase;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.play.ServerPlayNetHandler;
import net.minecraft.util.text.TextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.translation.LanguageMap;
import net.minecraftforge.fml.network.ConnectionType;
import net.minecraftforge.fml.network.NetworkHooks;
@@ -37,21 +37,21 @@ public class TextComponentHelper
* Detects when sending to a vanilla client and falls back to sending english,
* since they don't have the lang data necessary to translate on the client.
*/
public static TextComponentBase createComponentTranslation(ICommandSource source, final String translation, final Object... args)
public static TextComponent createComponentTranslation(ICommandSource source, final String translation, final Object... args)
{
if (isVanillaClient(source))
{
return new TextComponentString(String.format(LanguageMap.getInstance().translateKey(translation), args));
return new StringTextComponent(String.format(LanguageMap.getInstance().translateKey(translation), args));
}
return new TextComponentTranslation(translation, args);
return new TranslationTextComponent(translation, args);
}
private static boolean isVanillaClient(ICommandSource sender)
{
if (sender instanceof EntityPlayerMP)
if (sender instanceof ServerPlayerEntity)
{
EntityPlayerMP playerMP = (EntityPlayerMP) sender;
NetHandlerPlayServer channel = playerMP.connection;
ServerPlayerEntity playerMP = (ServerPlayerEntity) sender;
ServerPlayNetHandler channel = playerMP.connection;
return NetworkHooks.getConnectionType(()->channel.netManager) == ConnectionType.VANILLA;
}
return false;