mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Regenerate patches with relative headers. This should lower conflicts in future PRs.
Convert Forge to use Official mappings. Mojang released their obfuscation mappings but we have not used them up until now due to wanting to get their license to be more explicitly permissive. It is clear that their intent is to allow us to use their names for developing mods like this. See the full wording, and our interpretation here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
This commit is contained in:
1 parent
802298d99d
commit
a95b968c13
832 files changed
+4464
-4373
No files matched your search
@@ -66,16 +66,16 @@ public class ChunkGenWorker implements IWorker
|
||||
while (ret.size() < total)
|
||||
{
|
||||
for (int q = -radius + 1; q <= radius && ret.size() < total; q++)
|
||||
ret.add(start.add(radius, 0, q));
|
||||
ret.add(start.offset(radius, 0, q));
|
||||
|
||||
for (int q = radius - 1; q >= -radius && ret.size() < total; q--)
|
||||
ret.add(start.add(q, 0, radius));
|
||||
ret.add(start.offset(q, 0, radius));
|
||||
|
||||
for (int q = radius - 1; q >= -radius && ret.size() < total; q--)
|
||||
ret.add(start.add(-radius, 0, q));
|
||||
ret.add(start.offset(-radius, 0, q));
|
||||
|
||||
for (int q = -radius + 1; q <= radius && ret.size() < total; q++)
|
||||
ret.add(start.add(q, 0, -radius));
|
||||
ret.add(start.offset(q, 0, -radius));
|
||||
|
||||
radius++;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class ChunkGenWorker implements IWorker
|
||||
|
||||
if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60*1000)
|
||||
{
|
||||
listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true);
|
||||
listener.sendSuccess(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true);
|
||||
lastNotification = 0;
|
||||
lastNotifcationTime = System.currentTimeMillis();
|
||||
}
|
||||
@@ -130,9 +130,9 @@ public class ChunkGenWorker implements IWorker
|
||||
int x = next.getX();
|
||||
int z = next.getZ();
|
||||
|
||||
if (!dim.chunkExists(x, z)) { //Chunk is unloaded
|
||||
if (!dim.hasChunk(x, z)) { //Chunk is unloaded
|
||||
IChunk chunk = dim.getChunk(x, z, ChunkStatus.EMPTY, true);
|
||||
if (!chunk.getStatus().isAtLeast(ChunkStatus.FULL)) {
|
||||
if (!chunk.getStatus().isOrAfter(ChunkStatus.FULL)) {
|
||||
chunk = dim.getChunk(x, z, ChunkStatus.FULL);
|
||||
genned++; //There isn't a way to check if the chunk is actually created just if it was loaded
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class ChunkGenWorker implements IWorker
|
||||
|
||||
if (queue.size() == 0)
|
||||
{
|
||||
listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.complete", genned, total, dim.getDimensionKey().getLocation()), true);
|
||||
listener.sendSuccess(new TranslationTextComponent("commands.forge.gen.complete", genned, total, dim.dimension().location()), true);
|
||||
/* TODO: Readd if/when we introduce world unloading, or get Mojang to do it.
|
||||
if (keepingLoaded != null && !keepingLoaded)
|
||||
DimensionManager.keepLoaded(dim, false);
|
||||
|
||||
@@ -42,18 +42,18 @@ public class CommandDimensions
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("dimensions")
|
||||
.requires(cs->cs.hasPermissionLevel(0)) //permission
|
||||
.requires(cs->cs.hasPermission(0)) //permission
|
||||
.executes(ctx -> {
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.dimensions.list"), true);
|
||||
final Registry<DimensionType> reg = ctx.getSource().func_241861_q().getRegistry(Registry.DIMENSION_TYPE_KEY);
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.dimensions.list"), true);
|
||||
final Registry<DimensionType> reg = ctx.getSource().registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
|
||||
Map<ResourceLocation, List<ResourceLocation>> types = new HashMap<>();
|
||||
for (ServerWorld dim : ctx.getSource().getServer().getWorlds()) {
|
||||
types.computeIfAbsent(reg.getKey(dim.getDimensionType()), k -> new ArrayList<>()).add(dim.getDimensionKey().getLocation());
|
||||
for (ServerWorld dim : ctx.getSource().getServer().getAllLevels()) {
|
||||
types.computeIfAbsent(reg.getKey(dim.dimensionType()), k -> new ArrayList<>()).add(dim.dimension().location());
|
||||
}
|
||||
|
||||
types.keySet().stream().sorted().forEach(key -> {
|
||||
ctx.getSource().sendFeedback(new StringTextComponent(key + ": " + types.get(key).stream().map(ResourceLocation::toString).sorted().collect(Collectors.joining(", "))), false);
|
||||
ctx.getSource().sendSuccess(new StringTextComponent(key + ": " + types.get(key).stream().map(ResourceLocation::toString).sorted().collect(Collectors.joining(", "))), false);
|
||||
});
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -65,15 +65,15 @@ class CommandEntity
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("list")
|
||||
.requires(cs->cs.hasPermissionLevel(2)) //permission
|
||||
.requires(cs->cs.hasPermission(2)) //permission
|
||||
.then(Commands.argument("filter", StringArgumentType.string())
|
||||
.suggests((ctx, builder) -> ISuggestionProvider.suggest(ForgeRegistries.ENTITIES.getKeys().stream().map(ResourceLocation::toString).map(StringArgumentType::escapeIfRequired), builder))
|
||||
.then(Commands.argument("dim", DimensionArgument.getDimension())
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.getDimensionArgument(ctx, "dim").getDimensionKey()))
|
||||
.then(Commands.argument("dim", DimensionArgument.dimension())
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.getDimension(ctx, "dim").dimension()))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), ctx.getSource().getWorld().getDimensionKey()))
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), ctx.getSource().getLevel().dimension()))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), "*", ctx.getSource().getWorld().getDimensionKey()));
|
||||
.executes(ctx -> execute(ctx.getSource(), "*", ctx.getSource().getLevel().dimension()));
|
||||
}
|
||||
|
||||
private static int execute(CommandSource sender, String filter, RegistryKey<World> dim) throws CommandSyntaxException
|
||||
@@ -85,14 +85,14 @@ class CommandEntity
|
||||
if (names.isEmpty())
|
||||
throw INVALID_FILTER.create();
|
||||
|
||||
ServerWorld world = sender.getServer().getWorld(dim); //TODO: DimensionManager so we can hotload? DimensionManager.getWorld(sender.getServer(), dim, false, false);
|
||||
ServerWorld world = sender.getServer().getLevel(dim); //TODO: DimensionManager so we can hotload? 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();
|
||||
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());
|
||||
ChunkPos chunk = new ChunkPos(e.blockPosition());
|
||||
info.left++;
|
||||
info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1);
|
||||
});
|
||||
@@ -104,7 +104,7 @@ class CommandEntity
|
||||
if (info == null)
|
||||
throw NO_ENTITIES.create();
|
||||
|
||||
sender.sendFeedback(new TranslationTextComponent("commands.forge.entity.list.single.header", name, info.getLeft()), false);
|
||||
sender.sendSuccess(new TranslationTextComponent("commands.forge.entity.list.single.header", name, info.getLeft()), false);
|
||||
List<Map.Entry<ChunkPos, Integer>> toSort = new ArrayList<>();
|
||||
toSort.addAll(info.getRight().entrySet());
|
||||
toSort.sort((a, b) -> {
|
||||
@@ -118,7 +118,7 @@ class CommandEntity
|
||||
for (Map.Entry<ChunkPos, Integer> e : toSort)
|
||||
{
|
||||
if (limit-- == 0) break;
|
||||
sender.sendFeedback(new StringTextComponent(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z), false);
|
||||
sender.sendSuccess(new StringTextComponent(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z), false);
|
||||
}
|
||||
return toSort.size();
|
||||
}
|
||||
@@ -144,8 +144,8 @@ class CommandEntity
|
||||
throw NO_ENTITIES.create();
|
||||
|
||||
int count = info.stream().mapToInt(Pair::getRight).sum();
|
||||
sender.sendFeedback(new TranslationTextComponent("commands.forge.entity.list.multiple.header", count), false);
|
||||
info.forEach(e -> sender.sendFeedback(new StringTextComponent(" " + e.getValue() + ": " + e.getKey()), false));
|
||||
sender.sendSuccess(new TranslationTextComponent("commands.forge.entity.list.multiple.header", count), false);
|
||||
info.forEach(e -> sender.sendSuccess(new StringTextComponent(" " + e.getValue() + ": " + e.getKey()), false));
|
||||
return info.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,16 @@ class CommandGenerate
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("generate")
|
||||
.requires(cs->cs.hasPermissionLevel(4)) //permission
|
||||
.requires(cs->cs.hasPermission(4)) //permission
|
||||
.then(Commands.argument("pos", BlockPosArgument.blockPos())
|
||||
.then(Commands.argument("count", IntegerArgumentType.integer(1))
|
||||
.then(Commands.argument("dim", DimensionArgument.getDimension())
|
||||
.then(Commands.argument("dim", DimensionArgument.dimension())
|
||||
.then(Commands.argument("interval", IntegerArgumentType.integer())
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimensionArgument(ctx, "dim"), getInt(ctx, "interval")))
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getOrLoadBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimension(ctx, "dim"), getInt(ctx, "interval")))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimensionArgument(ctx, "dim"), -1))
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getOrLoadBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimension(ctx, "dim"), -1))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getWorld(), -1))
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getOrLoadBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getLevel(), -1))
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class CommandGenerate
|
||||
BlockPos chunkpos = new BlockPos(pos.getX() >> 4, 0, pos.getZ() >> 4);
|
||||
|
||||
ChunkGenWorker worker = new ChunkGenWorker(source, chunkpos, count, dim, interval);
|
||||
source.sendFeedback(worker.getStartMessage(source), true);
|
||||
source.sendSuccess(worker.getStartMessage(source), true);
|
||||
WorldWorkerManager.addWorker(worker);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -30,9 +30,9 @@ public class CommandModList {
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("mods")
|
||||
.requires(cs->cs.hasPermissionLevel(0)) //permission
|
||||
.requires(cs->cs.hasPermission(0)) //permission
|
||||
.executes(ctx -> {
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.mods.list",
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.mods.list",
|
||||
ModList.get().applyForEachModFile(modFile ->
|
||||
// locator - filename : firstmod (version) - numberofmods\n
|
||||
String.format("%s %s : %s (%s) - %d",
|
||||
|
||||
@@ -52,13 +52,13 @@ public class CommandSetDimension
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("setdimension")
|
||||
.requires(cs->cs.hasPermissionLevel(2)) //permission
|
||||
.requires(cs->cs.hasPermission(2)) //permission
|
||||
.then(Commands.argument("targets", EntityArgument.entities())
|
||||
.then(Commands.argument("dim", DimensionArgument.getDimension())
|
||||
.then(Commands.argument("dim", DimensionArgument.dimension())
|
||||
.then(Commands.argument("pos", BlockPosArgument.blockPos())
|
||||
.executes(ctx -> execute(ctx, EntityArgument.getEntitiesAllowingNone(ctx, "targets"), DimensionArgument.getDimensionArgument(ctx, "dim"), BlockPosArgument.getBlockPos(ctx, "pos")))
|
||||
.executes(ctx -> execute(ctx, EntityArgument.getOptionalEntities(ctx, "targets"), DimensionArgument.getDimension(ctx, "dim"), BlockPosArgument.getOrLoadBlockPos(ctx, "pos")))
|
||||
)
|
||||
.executes(ctx -> execute(ctx, EntityArgument.getEntitiesAllowingNone(ctx, "targets"), DimensionArgument.getDimensionArgument(ctx, "dim"), new BlockPos(ctx.getSource().getPos())))
|
||||
.executes(ctx -> execute(ctx, EntityArgument.getOptionalEntities(ctx, "targets"), DimensionArgument.getDimension(ctx, "dim"), new BlockPos(ctx.getSource().getPosition())))
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -86,12 +86,12 @@ public class CommandSetDimension
|
||||
}
|
||||
}
|
||||
}
|
||||
final String dimName = dim.getDimensionKey().getLocation().toString();
|
||||
final String dimName = dim.dimension().location().toString();
|
||||
final String finalCmdTarget = cmdTarget;
|
||||
final String finalPosTarget = posTarget;
|
||||
ITextComponent suggestion = new TranslationTextComponent("/execute in %s run tp %s%s", dimName, cmdTarget, finalPosTarget)
|
||||
.modifyStyle((style) -> style.setFormatting(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/execute in " + dimName + " run tp " + finalCmdTarget + finalPosTarget)));
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.setdim.deprecated", suggestion), true);
|
||||
.withStyle((style) -> style.withColor(TextFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/execute in " + dimName + " run tp " + finalCmdTarget + finalPosTarget)));
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.setdim.deprecated", suggestion), true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -99,6 +99,6 @@ public class CommandSetDimension
|
||||
private static boolean canEntityTeleport(Entity entity)
|
||||
{
|
||||
// use vanilla portal logic from BlockPortal#onEntityCollision
|
||||
return !entity.isPassenger() && !entity.isBeingRidden() && entity.isNonBoss();
|
||||
return !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions();
|
||||
}
|
||||
}
|
||||
@@ -38,18 +38,18 @@ class CommandTps
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("tps")
|
||||
.requires(cs->cs.hasPermissionLevel(0)) //permission
|
||||
.then(Commands.argument("dim", DimensionArgument.getDimension())
|
||||
.executes(ctx -> sendTime(ctx.getSource(), DimensionArgument.getDimensionArgument(ctx, "dim")))
|
||||
.requires(cs->cs.hasPermission(0)) //permission
|
||||
.then(Commands.argument("dim", DimensionArgument.dimension())
|
||||
.executes(ctx -> sendTime(ctx.getSource(), DimensionArgument.getDimension(ctx, "dim")))
|
||||
)
|
||||
.executes(ctx -> {
|
||||
for (ServerWorld dim : ctx.getSource().getServer().getWorlds())
|
||||
for (ServerWorld dim : ctx.getSource().getServer().getAllLevels())
|
||||
sendTime(ctx.getSource(), dim);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
double meanTickTime = mean(ctx.getSource().getServer().tickTimeArray) * 1.0E-6D;
|
||||
double meanTickTime = mean(ctx.getSource().getServer().tickTimes) * 1.0E-6D;
|
||||
double meanTPS = Math.min(1000.0/meanTickTime, 20);
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), false);
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -58,15 +58,15 @@ class CommandTps
|
||||
|
||||
private static int sendTime(CommandSource cs, ServerWorld dim) throws CommandSyntaxException
|
||||
{
|
||||
long[] times = cs.getServer().getTickTime(dim.getDimensionKey());
|
||||
long[] times = cs.getServer().getTickTime(dim.dimension());
|
||||
|
||||
if (times == null) // Null means the world is unloaded. Not invalid. That's taken car of by DimensionArgument itself.
|
||||
times = UNLOADED;
|
||||
|
||||
final Registry<DimensionType> reg = cs.func_241861_q().getRegistry(Registry.DIMENSION_TYPE_KEY);
|
||||
final Registry<DimensionType> reg = cs.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
double worldTickTime = mean(times) * 1.0E-6D;
|
||||
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
|
||||
cs.sendFeedback(new TranslationTextComponent("commands.forge.tps.summary.named", dim.getDimensionKey().getLocation().toString(), reg.getKey(dim.getDimensionType()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);
|
||||
cs.sendSuccess(new TranslationTextComponent("commands.forge.tps.summary.named", dim.dimension().location().toString(), reg.getKey(dim.dimensionType()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ class CommandTrack
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("start")
|
||||
.requires(cs->cs.hasPermissionLevel(2)) //permission
|
||||
.requires(cs->cs.hasPermission(2)) //permission
|
||||
.then(Commands.literal("te")
|
||||
.then(Commands.argument("duration", IntegerArgumentType.integer(1))
|
||||
.executes(ctx -> {
|
||||
int duration = IntegerArgumentType.getInteger(ctx, "duration");
|
||||
TimeTracker.TILE_ENTITY_UPDATE.reset();
|
||||
TimeTracker.TILE_ENTITY_UPDATE.enable(duration);
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.te.enabled", duration), true);
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.te.enabled", duration), true);
|
||||
return 0;
|
||||
})
|
||||
)
|
||||
@@ -76,7 +76,7 @@ class CommandTrack
|
||||
int duration = IntegerArgumentType.getInteger(ctx, "duration");
|
||||
TimeTracker.ENTITY_UPDATE.reset();
|
||||
TimeTracker.ENTITY_UPDATE.enable(duration);
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.entity.enabled", duration), true);
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.entity.enabled", duration), true);
|
||||
return 0;
|
||||
})
|
||||
)
|
||||
@@ -89,18 +89,18 @@ class CommandTrack
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("reset")
|
||||
.requires(cs->cs.hasPermissionLevel(2)) //permission
|
||||
.requires(cs->cs.hasPermission(2)) //permission
|
||||
.then(Commands.literal("te")
|
||||
.executes(ctx -> {
|
||||
TimeTracker.TILE_ENTITY_UPDATE.reset();
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.te.reset"), true);
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.te.reset"), true);
|
||||
return 0;
|
||||
})
|
||||
)
|
||||
.then(Commands.literal("entity")
|
||||
.executes(ctx -> {
|
||||
TimeTracker.ENTITY_UPDATE.reset();
|
||||
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.tracking.entity.reset"), true);
|
||||
ctx.getSource().sendSuccess(new TranslationTextComponent("commands.forge.tracking.entity.reset"), true);
|
||||
return 0;
|
||||
})
|
||||
);
|
||||
@@ -130,14 +130,14 @@ class CommandTrack
|
||||
List<ForgeTimings<T>> timingsList = getSortedTimings(tracker);
|
||||
if (timingsList.isEmpty())
|
||||
{
|
||||
source.sendFeedback(new TranslationTextComponent("commands.forge.tracking.no_data"), true);
|
||||
source.sendSuccess(new TranslationTextComponent("commands.forge.tracking.no_data"), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
timingsList.stream()
|
||||
.filter(timings -> timings.getObject().get() != null)
|
||||
.limit(10)
|
||||
.forEach(timings -> source.sendFeedback(toString.apply(timings), true));
|
||||
.forEach(timings -> source.sendSuccess(toString.apply(timings), true));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -153,11 +153,11 @@ class CommandTrack
|
||||
if (entity == null)
|
||||
return new TranslationTextComponent("commands.forge.tracking.invalid");
|
||||
|
||||
BlockPos pos = entity.getPosition();
|
||||
BlockPos pos = entity.blockPosition();
|
||||
double averageTimings = data.getAverageTimings();
|
||||
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms");
|
||||
|
||||
return new TranslationTextComponent("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), entity.world.getDimensionKey().getLocation().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
return new TranslationTextComponent("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), entity.level.dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -173,11 +173,11 @@ class CommandTrack
|
||||
if (te == null)
|
||||
return new TranslationTextComponent("commands.forge.tracking.invalid");
|
||||
|
||||
BlockPos pos = te.getPos();
|
||||
BlockPos pos = te.getBlockPos();
|
||||
|
||||
double averageTimings = data.getAverageTimings();
|
||||
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms");
|
||||
return new TranslationTextComponent("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), te.getWorld().getDimensionKey().getLocation().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
return new TranslationTextComponent("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), te.getLevel().dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ConfigCommand {
|
||||
public static class ShowFile {
|
||||
static ArgumentBuilder<CommandSource, ?> register() {
|
||||
return Commands.literal("showfile").
|
||||
requires(cs->cs.hasPermissionLevel(0)).
|
||||
requires(cs->cs.hasPermission(0)).
|
||||
then(Commands.argument("mod", ModIdArgument.modIdArgument()).
|
||||
then(Commands.argument("type", EnumArgument.enumArgument(ModConfig.Type.class)).
|
||||
executes(ShowFile::showFile)
|
||||
@@ -58,13 +58,13 @@ public class ConfigCommand {
|
||||
final String configFileName = ConfigTracker.INSTANCE.getConfigFileName(modId, type);
|
||||
if (configFileName != null) {
|
||||
File f = new File(configFileName);
|
||||
context.getSource().sendFeedback(new TranslationTextComponent("commands.config.getwithtype",
|
||||
context.getSource().sendSuccess(new TranslationTextComponent("commands.config.getwithtype",
|
||||
modId, type,
|
||||
new StringTextComponent(f.getName()).mergeStyle(TextFormatting.UNDERLINE).
|
||||
modifyStyle((style) -> style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getAbsolutePath())))
|
||||
new StringTextComponent(f.getName()).withStyle(TextFormatting.UNDERLINE).
|
||||
withStyle((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getAbsolutePath())))
|
||||
), true);
|
||||
} else {
|
||||
context.getSource().sendFeedback(new TranslationTextComponent("commands.config.noconfig", modId, type),
|
||||
context.getSource().sendSuccess(new TranslationTextComponent("commands.config.noconfig", modId, type),
|
||||
true);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -63,18 +63,18 @@ public class EnumArgument<T extends Enum<T>> implements ArgumentType<T> {
|
||||
public static class Serializer implements IArgumentSerializer<EnumArgument<?>>
|
||||
{
|
||||
@Override
|
||||
public void write(EnumArgument<?> argument, PacketBuffer buffer)
|
||||
public void serializeToNetwork(EnumArgument<?> argument, PacketBuffer buffer)
|
||||
{
|
||||
buffer.writeString(argument.enumClass.getName());
|
||||
buffer.writeUtf(argument.enumClass.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public EnumArgument<?> read(PacketBuffer buffer)
|
||||
public EnumArgument<?> deserializeFromNetwork(PacketBuffer buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
String name = buffer.readString();
|
||||
String name = buffer.readUtf();
|
||||
return new EnumArgument(Class.forName(name));
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
@@ -84,7 +84,7 @@ public class EnumArgument<T extends Enum<T>> implements ArgumentType<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(EnumArgument<?> argument, JsonObject json)
|
||||
public void serializeToJson(EnumArgument<?> argument, JsonObject json)
|
||||
{
|
||||
json.addProperty("enum", argument.enumClass.getName());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TextComponentHelper
|
||||
{
|
||||
if (isVanillaClient(source))
|
||||
{
|
||||
return new StringTextComponent(String.format(LanguageMap.getInstance().func_230503_a_(translation), args));
|
||||
return new StringTextComponent(String.format(LanguageMap.getInstance().getOrDefault(translation), args));
|
||||
}
|
||||
return new TranslationTextComponent(translation, args);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class TextComponentHelper
|
||||
{
|
||||
ServerPlayerEntity playerMP = (ServerPlayerEntity) sender;
|
||||
ServerPlayNetHandler channel = playerMP.connection;
|
||||
return NetworkHooks.getConnectionType(()->channel.netManager) == ConnectionType.VANILLA;
|
||||
return NetworkHooks.getConnectionType(()->channel.connection) == ConnectionType.VANILLA;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user