Setup and import of 1.16 YEET

This commit is contained in:
cpw committed 2020-06-25 17:55:38 -04:00
1 parent 56397043bb
commit 6d15febdb3
931 files changed
+18847 -9127

No files matched your search

@@ -27,10 +27,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.DimensionType;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.WorldWorkerManager.IWorker;
public class ChunkGenWorker implements IWorker
@@ -38,7 +37,7 @@ public class ChunkGenWorker implements IWorker
private final CommandSource listener;
protected final BlockPos start;
protected final int total;
private final DimensionType dim;
private final ServerWorld dim;
private final Queue<BlockPos> queue;
private final int notificationFrequency;
private int lastNotification = 0;
@@ -46,7 +45,7 @@ public class ChunkGenWorker implements IWorker
private int genned = 0;
private Boolean keepingLoaded;
public ChunkGenWorker(CommandSource listener, BlockPos start, int total, DimensionType dim, int interval)
public ChunkGenWorker(CommandSource listener, BlockPos start, int total, ServerWorld dim, int interval)
{
this.listener = listener;
this.start = start;
@@ -97,6 +96,7 @@ public class ChunkGenWorker implements IWorker
@Override
public boolean doWork()
{
/*
ServerWorld world = DimensionManager.getWorld(listener.getServer(), dim, false, false);
if (world == null)
{
@@ -121,7 +121,7 @@ public class ChunkGenWorker implements IWorker
}
return false;
}
*/
* /
BlockPos next = queue.poll();
@@ -161,6 +161,7 @@ public class ChunkGenWorker implements IWorker
}
return false;
}
*/
return true;
}
}
@@ -23,7 +23,6 @@ import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
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;
import java.util.List;
@@ -40,6 +39,7 @@ public class CommandDimensions
.requires(cs->cs.hasPermissionLevel(0)) //permission
.executes(ctx -> {
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.dimensions.list"), true);
/*
Map<String, List<String>> types = new HashMap<>();
for (DimensionType dim : DimensionType.getAll()) {
String key = dim.getModType() == null ? "Vanilla" : dim.getModType().getRegistryName().toString();
@@ -49,6 +49,10 @@ public class CommandDimensions
types.keySet().stream().sorted().forEach(key -> {
ctx.getSource().sendFeedback(new StringTextComponent(key + ": " + types.get(key).stream().sorted().collect(Collectors.joining(", "))), false);
});
*/
ctx.getSource().getServer().func_240770_D_().stream().sorted().forEach(key -> {
ctx.getSource().sendFeedback(new StringTextComponent(key.func_240901_a_().toString()), false);
});
return 0;
});
}
@@ -38,13 +38,14 @@ import net.minecraft.command.Commands;
import net.minecraft.command.ISuggestionProvider;
import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.entity.Entity;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.commons.lang3.tuple.MutablePair;
@@ -70,14 +71,14 @@ class CommandEntity
.then(Commands.argument("filter", StringArgumentType.string())
.suggests((ctx, builder) -> ISuggestionProvider.suggest(ForgeRegistries.ENTITIES.getKeys().stream().map(ResourceLocation::toString), builder))
.then(Commands.argument("dim", DimensionArgument.getDimension())
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.getDimensionArgument(ctx, "dim")))
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.getDimensionArgument(ctx, "dim").func_234923_W_()))
)
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), ctx.getSource().getWorld().dimension.getType()))
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), ctx.getSource().getWorld().func_234923_W_()))
)
.executes(ctx -> execute(ctx.getSource(), "*", ctx.getSource().getWorld().dimension.getType()));
.executes(ctx -> execute(ctx.getSource(), "*", ctx.getSource().getWorld().func_234923_W_()));
}
private static int execute(CommandSource sender, String filter, DimensionType dim) throws CommandSyntaxException
private static int execute(CommandSource sender, String filter, RegistryKey<World> dim) throws CommandSyntaxException
{
final String cleanFilter = filter.replace("?", ".?").replace("*", ".*?");
@@ -86,14 +87,14 @@ class CommandEntity
if (names.isEmpty())
throw INVALID_FILTER.create();
ServerWorld world = DimensionManager.getWorld(sender.getServer(), dim, false, false);
ServerWorld world = sender.getServer().getWorld(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.func_233580_cy_());
info.left++;
info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1);
});
@@ -29,7 +29,7 @@ import net.minecraft.command.Commands;
import net.minecraft.command.arguments.BlockPosArgument;
import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.WorldWorkerManager;
class CommandGenerate
@@ -46,7 +46,7 @@ class CommandGenerate
)
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimensionArgument(ctx, "dim"), -1))
)
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getWorld().dimension.getType(), -1))
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getWorld(), -1))
)
);
}
@@ -56,7 +56,7 @@ class CommandGenerate
return IntegerArgumentType.getInteger(ctx, name);
}
private static int execute(CommandSource source, BlockPos pos, int count, DimensionType dim, int interval) throws CommandException
private static int execute(CommandSource source, BlockPos pos, int count, ServerWorld dim, int interval) throws CommandException
{
BlockPos chunkpos = new BlockPos(pos.getX() >> 4, 0, pos.getZ() >> 4);
@@ -27,7 +27,6 @@ import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.ITeleporter;
@@ -56,8 +55,8 @@ public class CommandSetDimension
)
);
}
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException
private static int execute(CommandSource sender, Collection<? extends Entity> entities, ServerWorld dim, BlockPos pos) throws CommandSyntaxException
{
entities.removeIf(e -> !canEntityTeleport(e));
if (entities.isEmpty())
@@ -66,8 +65,8 @@ public class CommandSetDimension
//if (!DimensionManager.isDimensionRegistered(dim))
// throw INVALID_DIMENSION.create(dim);
entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getFormattedText(), dim), true));
entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, new ITeleporter()
entities.stream().filter(e -> e.world == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getString(), dim), true));
entities.stream().filter(e -> e.world != dim).forEach(e -> e.func_241206_a_(dim/* TODO: Custom Teleporters , new ITeleporter()
{
@Override
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function<Boolean, Entity> repositionEntity)
@@ -76,7 +75,8 @@ public class CommandSetDimension
repositionedEntity.setPositionAndUpdate(pos.getX(), pos.getY(), pos.getZ());
return repositionedEntity;
}
}));
}*/));
return 0;
}
@@ -26,7 +26,7 @@ import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
class CommandTps
{
@@ -41,7 +41,7 @@ class CommandTps
.executes(ctx -> sendTime(ctx.getSource(), DimensionArgument.getDimensionArgument(ctx, "dim")))
)
.executes(ctx -> {
for (DimensionType dim : DimensionType.getAll())
for (ServerWorld dim : ctx.getSource().getServer().getWorlds())
sendTime(ctx.getSource(), dim);
double meanTickTime = mean(ctx.getSource().getServer().tickTimeArray) * 1.0E-6D;
@@ -53,16 +53,16 @@ class CommandTps
);
}
private static int sendTime(CommandSource cs, DimensionType dim) throws CommandSyntaxException
private static int sendTime(CommandSource cs, ServerWorld dim) throws CommandSyntaxException
{
long[] times = cs.getServer().getTickTime(dim);
long[] times = cs.getServer().getTickTime(dim.func_234923_W_());
if (times == null) // Null means the world is unloaded. Not invalid. That's taken car of by DimensionArgument itself.
times = UNLOADED;
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.getId(), DimensionType.getKey(dim), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);
cs.sendFeedback(new TranslationTextComponent("commands.forge.tps.summary.named", dim.func_234923_W_().toString(), dim.func_234922_V_().toString(), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);
return 1;
}
@@ -36,7 +36,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.server.timings.ForgeTimings;
import net.minecraftforge.server.timings.TimeTracker;
@@ -154,11 +153,11 @@ class CommandTrack
if (entity == null)
return new TranslationTextComponent("commands.forge.tracking.invalid");
BlockPos pos = entity.getPosition();
BlockPos pos = entity.func_233580_cy_();
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(), DimensionType.getKey(entity.world.dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
return new TranslationTextComponent("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), entity.world.func_234923_W_().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
})
);
}
@@ -178,7 +177,7 @@ class CommandTrack
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(), DimensionType.getKey(te.getWorld().dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
return new TranslationTextComponent("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), te.getWorld().func_234923_W_().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
})
);
}
@@ -60,8 +60,8 @@ public class ConfigCommand {
File f = new File(configFileName);
context.getSource().sendFeedback(new TranslationTextComponent("commands.config.getwithtype",
modId, type,
new StringTextComponent(f.getName()).applyTextStyle(TextFormatting.UNDERLINE).
applyTextStyle((style) -> style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getAbsolutePath())))
new StringTextComponent(f.getName()).func_240701_a_(TextFormatting.UNDERLINE).
func_240700_a_((style) -> style.func_240715_a_(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getAbsolutePath())))
), true);
} else {
context.getSource().sendFeedback(new TranslationTextComponent("commands.config.noconfig", modId, type),
@@ -41,7 +41,7 @@ public class TextComponentHelper
{
if (isVanillaClient(source))
{
return new StringTextComponent(String.format(LanguageMap.getInstance().translateKey(translation), args));
return new StringTextComponent(String.format(LanguageMap.getInstance().func_230503_a_(translation), args));
}
return new TranslationTextComponent(translation, args);
}