aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/commands/PlaceCommand.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/commands/PlaceCommand.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/server/commands/PlaceCommand.java.patch208
1 files changed, 208 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/commands/PlaceCommand.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/commands/PlaceCommand.java.patch
new file mode 100644
index 0000000000..6a92ffd458
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/server/commands/PlaceCommand.java.patch
@@ -0,0 +1,208 @@
+--- a/net/minecraft/server/commands/PlaceCommand.java
++++ b/net/minecraft/server/commands/PlaceCommand.java
+@@ -12,7 +12,6 @@
+ import java.util.Optional;
+ import net.minecraft.ResourceLocationException;
+ import net.minecraft.commands.CommandSourceStack;
+-import net.minecraft.commands.Commands;
+ import net.minecraft.commands.SharedSuggestionProvider;
+ import net.minecraft.commands.arguments.ResourceKeyArgument;
+ import net.minecraft.commands.arguments.ResourceLocationArgument;
+@@ -59,135 +58,136 @@
+
+ public PlaceCommand() {}
+
+- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher) {
+- commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("place").requires((commandsourcestack) -> {
+- return commandsourcestack.hasPermission(2);
+- })).then(Commands.literal("feature").then(((RequiredArgumentBuilder) Commands.argument("feature", ResourceKeyArgument.key(Registries.CONFIGURED_FEATURE)).executes((commandcontext) -> {
++ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("place").requires((commandlistenerwrapper) -> {
++ return commandlistenerwrapper.hasPermission(2);
++ })).then(net.minecraft.commands.Commands.literal("feature").then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("feature", ResourceKeyArgument.key(Registries.CONFIGURED_FEATURE)).executes((commandcontext) -> {
+ return placeFeature((CommandSourceStack) commandcontext.getSource(), ResourceKeyArgument.getConfiguredFeature(commandcontext, "feature"), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()));
+- })).then(Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
++ })).then(net.minecraft.commands.Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
+ return placeFeature((CommandSourceStack) commandcontext.getSource(), ResourceKeyArgument.getConfiguredFeature(commandcontext, "feature"), BlockPosArgument.getLoadedBlockPos(commandcontext, "pos"));
+- }))))).then(Commands.literal("jigsaw").then(Commands.argument("pool", ResourceKeyArgument.key(Registries.TEMPLATE_POOL)).then(Commands.argument("target", ResourceLocationArgument.id()).then(((RequiredArgumentBuilder) Commands.argument("max_depth", IntegerArgumentType.integer(1, 7)).executes((commandcontext) -> {
++ }))))).then(net.minecraft.commands.Commands.literal("jigsaw").then(net.minecraft.commands.Commands.argument("pool", ResourceKeyArgument.key(Registries.TEMPLATE_POOL)).then(net.minecraft.commands.Commands.argument("target", ResourceLocationArgument.id()).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("max_depth", IntegerArgumentType.integer(1, 7)).executes((commandcontext) -> {
+ return placeJigsaw((CommandSourceStack) commandcontext.getSource(), ResourceKeyArgument.getStructureTemplatePool(commandcontext, "pool"), ResourceLocationArgument.getId(commandcontext, "target"), IntegerArgumentType.getInteger(commandcontext, "max_depth"), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()));
+- })).then(Commands.argument("position", BlockPosArgument.blockPos()).executes((commandcontext) -> {
++ })).then(net.minecraft.commands.Commands.argument("position", BlockPosArgument.blockPos()).executes((commandcontext) -> {
+ return placeJigsaw((CommandSourceStack) commandcontext.getSource(), ResourceKeyArgument.getStructureTemplatePool(commandcontext, "pool"), ResourceLocationArgument.getId(commandcontext, "target"), IntegerArgumentType.getInteger(commandcontext, "max_depth"), BlockPosArgument.getLoadedBlockPos(commandcontext, "position"));
+- }))))))).then(Commands.literal("structure").then(((RequiredArgumentBuilder) Commands.argument("structure", ResourceKeyArgument.key(Registries.STRUCTURE)).executes((commandcontext) -> {
++ }))))))).then(net.minecraft.commands.Commands.literal("structure").then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("structure", ResourceKeyArgument.key(Registries.STRUCTURE)).executes((commandcontext) -> {
+ return placeStructure((CommandSourceStack) commandcontext.getSource(), ResourceKeyArgument.getStructure(commandcontext, "structure"), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()));
+- })).then(Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
++ })).then(net.minecraft.commands.Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
+ return placeStructure((CommandSourceStack) commandcontext.getSource(), ResourceKeyArgument.getStructure(commandcontext, "structure"), BlockPosArgument.getLoadedBlockPos(commandcontext, "pos"));
+- }))))).then(Commands.literal("template").then(((RequiredArgumentBuilder) Commands.argument("template", ResourceLocationArgument.id()).suggests(PlaceCommand.SUGGEST_TEMPLATES).executes((commandcontext) -> {
++ }))))).then(net.minecraft.commands.Commands.literal("template").then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("template", ResourceLocationArgument.id()).suggests(PlaceCommand.SUGGEST_TEMPLATES).executes((commandcontext) -> {
+ return placeTemplate((CommandSourceStack) commandcontext.getSource(), ResourceLocationArgument.getId(commandcontext, "template"), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()), Rotation.NONE, Mirror.NONE, 1.0F, 0);
+- })).then(((RequiredArgumentBuilder) Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
+ return placeTemplate((CommandSourceStack) commandcontext.getSource(), ResourceLocationArgument.getId(commandcontext, "template"), BlockPosArgument.getLoadedBlockPos(commandcontext, "pos"), Rotation.NONE, Mirror.NONE, 1.0F, 0);
+- })).then(((RequiredArgumentBuilder) Commands.argument("rotation", TemplateRotationArgument.templateRotation()).executes((commandcontext) -> {
++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("rotation", TemplateRotationArgument.templateRotation()).executes((commandcontext) -> {
+ return placeTemplate((CommandSourceStack) commandcontext.getSource(), ResourceLocationArgument.getId(commandcontext, "template"), BlockPosArgument.getLoadedBlockPos(commandcontext, "pos"), TemplateRotationArgument.getRotation(commandcontext, "rotation"), Mirror.NONE, 1.0F, 0);
+- })).then(((RequiredArgumentBuilder) Commands.argument("mirror", TemplateMirrorArgument.templateMirror()).executes((commandcontext) -> {
++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("mirror", TemplateMirrorArgument.templateMirror()).executes((commandcontext) -> {
+ return placeTemplate((CommandSourceStack) commandcontext.getSource(), ResourceLocationArgument.getId(commandcontext, "template"), BlockPosArgument.getLoadedBlockPos(commandcontext, "pos"), TemplateRotationArgument.getRotation(commandcontext, "rotation"), TemplateMirrorArgument.getMirror(commandcontext, "mirror"), 1.0F, 0);
+- })).then(((RequiredArgumentBuilder) Commands.argument("integrity", FloatArgumentType.floatArg(0.0F, 1.0F)).executes((commandcontext) -> {
++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("integrity", FloatArgumentType.floatArg(0.0F, 1.0F)).executes((commandcontext) -> {
+ return placeTemplate((CommandSourceStack) commandcontext.getSource(), ResourceLocationArgument.getId(commandcontext, "template"), BlockPosArgument.getLoadedBlockPos(commandcontext, "pos"), TemplateRotationArgument.getRotation(commandcontext, "rotation"), TemplateMirrorArgument.getMirror(commandcontext, "mirror"), FloatArgumentType.getFloat(commandcontext, "integrity"), 0);
+- })).then(Commands.argument("seed", IntegerArgumentType.integer()).executes((commandcontext) -> {
++ })).then(net.minecraft.commands.Commands.argument("seed", IntegerArgumentType.integer()).executes((commandcontext) -> {
+ return placeTemplate((CommandSourceStack) commandcontext.getSource(), ResourceLocationArgument.getId(commandcontext, "template"), BlockPosArgument.getLoadedBlockPos(commandcontext, "pos"), TemplateRotationArgument.getRotation(commandcontext, "rotation"), TemplateMirrorArgument.getMirror(commandcontext, "mirror"), FloatArgumentType.getFloat(commandcontext, "integrity"), IntegerArgumentType.getInteger(commandcontext, "seed"));
+ })))))))));
+ }
+
+- public static int placeFeature(CommandSourceStack commandsourcestack, Holder.Reference<ConfiguredFeature<?, ?>> holder_reference, BlockPos blockpos) throws CommandSyntaxException {
+- ServerLevel serverlevel = commandsourcestack.getLevel();
+- ConfiguredFeature<?, ?> configuredfeature = (ConfiguredFeature) holder_reference.value();
+- ChunkPos chunkpos = new ChunkPos(blockpos);
++ public static int placeFeature(CommandSourceStack source, Holder.Reference<ConfiguredFeature<?, ?>> feature, BlockPos pos) throws CommandSyntaxException {
++ ServerLevel worldserver = source.getLevel();
++ ConfiguredFeature<?, ?> worldgenfeatureconfigured = (ConfiguredFeature) feature.value();
++ ChunkPos chunkcoordintpair = new ChunkPos(pos);
+
+- checkLoaded(serverlevel, new ChunkPos(chunkpos.x - 1, chunkpos.z - 1), new ChunkPos(chunkpos.x + 1, chunkpos.z + 1));
+- if (!configuredfeature.place(serverlevel, serverlevel.getChunkSource().getGenerator(), serverlevel.getRandom(), blockpos)) {
++ checkLoaded(worldserver, new ChunkPos(chunkcoordintpair.x - 1, chunkcoordintpair.z - 1), new ChunkPos(chunkcoordintpair.x + 1, chunkcoordintpair.z + 1));
++ if (!worldgenfeatureconfigured.place(worldserver, worldserver.getChunkSource().getGenerator(), worldserver.getRandom(), pos)) {
+ throw PlaceCommand.ERROR_FEATURE_FAILED.create();
+ } else {
+- String s = holder_reference.key().location().toString();
++ String s = feature.key().location().toString();
+
+- commandsourcestack.sendSuccess(() -> {
+- return Component.translatable("commands.place.feature.success", s, blockpos.getX(), blockpos.getY(), blockpos.getZ());
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.place.feature.success", s, pos.getX(), pos.getY(), pos.getZ());
+ }, true);
+ return 1;
+ }
+ }
+
+- public static int placeJigsaw(CommandSourceStack commandsourcestack, Holder<StructureTemplatePool> holder, ResourceLocation resourcelocation, int i, BlockPos blockpos) throws CommandSyntaxException {
+- ServerLevel serverlevel = commandsourcestack.getLevel();
++ public static int placeJigsaw(CommandSourceStack source, Holder<StructureTemplatePool> templatePool, ResourceLocation target, int maxDepth, BlockPos pos) throws CommandSyntaxException {
++ ServerLevel worldserver = source.getLevel();
+
+- if (!JigsawPlacement.generateJigsaw(serverlevel, holder, resourcelocation, i, blockpos, false)) {
++ if (!JigsawPlacement.generateJigsaw(worldserver, templatePool, target, maxDepth, pos, false)) {
+ throw PlaceCommand.ERROR_JIGSAW_FAILED.create();
+ } else {
+- commandsourcestack.sendSuccess(() -> {
+- return Component.translatable("commands.place.jigsaw.success", blockpos.getX(), blockpos.getY(), blockpos.getZ());
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.place.jigsaw.success", pos.getX(), pos.getY(), pos.getZ());
+ }, true);
+ return 1;
+ }
+ }
+
+- public static int placeStructure(CommandSourceStack commandsourcestack, Holder.Reference<Structure> holder_reference, BlockPos blockpos) throws CommandSyntaxException {
+- ServerLevel serverlevel = commandsourcestack.getLevel();
+- Structure structure = (Structure) holder_reference.value();
+- ChunkGenerator chunkgenerator = serverlevel.getChunkSource().getGenerator();
+- StructureStart structurestart = structure.generate(commandsourcestack.registryAccess(), chunkgenerator, chunkgenerator.getBiomeSource(), serverlevel.getChunkSource().randomState(), serverlevel.getStructureManager(), serverlevel.getSeed(), new ChunkPos(blockpos), 0, serverlevel, (holder) -> {
++ public static int placeStructure(CommandSourceStack source, Holder.Reference<Structure> structure, BlockPos pos) throws CommandSyntaxException {
++ ServerLevel worldserver = source.getLevel();
++ Structure structure1 = (Structure) structure.value();
++ ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator();
++ StructureStart structurestart = structure1.generate(source.registryAccess(), chunkgenerator, chunkgenerator.getBiomeSource(), worldserver.getChunkSource().randomState(), worldserver.getStructureManager(), worldserver.getSeed(), new ChunkPos(pos), 0, worldserver, (holder) -> {
+ return true;
+ });
+
+ if (!structurestart.isValid()) {
+ throw PlaceCommand.ERROR_STRUCTURE_FAILED.create();
+ } else {
+- BoundingBox boundingbox = structurestart.getBoundingBox();
+- ChunkPos chunkpos = new ChunkPos(SectionPos.blockToSectionCoord(boundingbox.minX()), SectionPos.blockToSectionCoord(boundingbox.minZ()));
+- ChunkPos chunkpos1 = new ChunkPos(SectionPos.blockToSectionCoord(boundingbox.maxX()), SectionPos.blockToSectionCoord(boundingbox.maxZ()));
++ structurestart.generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.COMMAND; // CraftBukkit - set AsyncStructureGenerateEvent.Cause.COMMAND as generation cause
++ BoundingBox structureboundingbox = structurestart.getBoundingBox();
++ ChunkPos chunkcoordintpair = new ChunkPos(SectionPos.blockToSectionCoord(structureboundingbox.minX()), SectionPos.blockToSectionCoord(structureboundingbox.minZ()));
++ ChunkPos chunkcoordintpair1 = new ChunkPos(SectionPos.blockToSectionCoord(structureboundingbox.maxX()), SectionPos.blockToSectionCoord(structureboundingbox.maxZ()));
+
+- checkLoaded(serverlevel, chunkpos, chunkpos1);
+- ChunkPos.rangeClosed(chunkpos, chunkpos1).forEach((chunkpos2) -> {
+- structurestart.placeInChunk(serverlevel, serverlevel.structureManager(), chunkgenerator, serverlevel.getRandom(), new BoundingBox(chunkpos2.getMinBlockX(), serverlevel.getMinBuildHeight(), chunkpos2.getMinBlockZ(), chunkpos2.getMaxBlockX(), serverlevel.getMaxBuildHeight(), chunkpos2.getMaxBlockZ()), chunkpos2);
++ checkLoaded(worldserver, chunkcoordintpair, chunkcoordintpair1);
++ ChunkPos.rangeClosed(chunkcoordintpair, chunkcoordintpair1).forEach((chunkcoordintpair2) -> {
++ structurestart.placeInChunk(worldserver, worldserver.structureManager(), chunkgenerator, worldserver.getRandom(), new BoundingBox(chunkcoordintpair2.getMinBlockX(), worldserver.getMinBuildHeight(), chunkcoordintpair2.getMinBlockZ(), chunkcoordintpair2.getMaxBlockX(), worldserver.getMaxBuildHeight(), chunkcoordintpair2.getMaxBlockZ()), chunkcoordintpair2);
+ });
+- String s = holder_reference.key().location().toString();
++ String s = structure.key().location().toString();
+
+- commandsourcestack.sendSuccess(() -> {
+- return Component.translatable("commands.place.structure.success", s, blockpos.getX(), blockpos.getY(), blockpos.getZ());
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.place.structure.success", s, pos.getX(), pos.getY(), pos.getZ());
+ }, true);
+ return 1;
+ }
+ }
+
+- public static int placeTemplate(CommandSourceStack commandsourcestack, ResourceLocation resourcelocation, BlockPos blockpos, Rotation rotation, Mirror mirror, float f, int i) throws CommandSyntaxException {
+- ServerLevel serverlevel = commandsourcestack.getLevel();
+- StructureTemplateManager structuretemplatemanager = serverlevel.getStructureManager();
++ public static int placeTemplate(CommandSourceStack source, ResourceLocation template, BlockPos pos, Rotation rotation, Mirror mirror, float integrity, int seed) throws CommandSyntaxException {
++ ServerLevel worldserver = source.getLevel();
++ StructureTemplateManager structuretemplatemanager = worldserver.getStructureManager();
+
+ Optional optional;
+
+ try {
+- optional = structuretemplatemanager.get(resourcelocation);
+- } catch (ResourceLocationException resourcelocationexception) {
+- throw PlaceCommand.ERROR_TEMPLATE_INVALID.create(resourcelocation);
++ optional = structuretemplatemanager.get(template);
++ } catch (ResourceLocationException resourcekeyinvalidexception) {
++ throw PlaceCommand.ERROR_TEMPLATE_INVALID.create(template);
+ }
+
+ if (optional.isEmpty()) {
+- throw PlaceCommand.ERROR_TEMPLATE_INVALID.create(resourcelocation);
++ throw PlaceCommand.ERROR_TEMPLATE_INVALID.create(template);
+ } else {
+- StructureTemplate structuretemplate = (StructureTemplate) optional.get();
++ StructureTemplate definedstructure = (StructureTemplate) optional.get();
+
+- checkLoaded(serverlevel, new ChunkPos(blockpos), new ChunkPos(blockpos.offset(structuretemplate.getSize())));
+- StructurePlaceSettings structureplacesettings = (new StructurePlaceSettings()).setMirror(mirror).setRotation(rotation);
++ checkLoaded(worldserver, new ChunkPos(pos), new ChunkPos(pos.offset(definedstructure.getSize())));
++ StructurePlaceSettings definedstructureinfo = (new StructurePlaceSettings()).setMirror(mirror).setRotation(rotation);
+
+- if (f < 1.0F) {
+- structureplacesettings.clearProcessors().addProcessor(new BlockRotProcessor(f)).setRandom(StructureBlockEntity.createRandom((long) i));
++ if (integrity < 1.0F) {
++ definedstructureinfo.clearProcessors().addProcessor(new BlockRotProcessor(integrity)).setRandom(StructureBlockEntity.createRandom((long) seed));
+ }
+
+- boolean flag = structuretemplate.placeInWorld(serverlevel, blockpos, blockpos, structureplacesettings, StructureBlockEntity.createRandom((long) i), 2);
++ boolean flag = definedstructure.placeInWorld(worldserver, pos, pos, definedstructureinfo, StructureBlockEntity.createRandom((long) seed), 2);
+
+ if (!flag) {
+ throw PlaceCommand.ERROR_TEMPLATE_FAILED.create();
+ } else {
+- commandsourcestack.sendSuccess(() -> {
+- return Component.translatable("commands.place.template.success", Component.translationArg(resourcelocation), blockpos.getX(), blockpos.getY(), blockpos.getZ());
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.place.template.success", Component.translationArg(template), pos.getX(), pos.getY(), pos.getZ());
+ }, true);
+ return 1;
+ }
+ }
+ }
+
+- private static void checkLoaded(ServerLevel serverlevel, ChunkPos chunkpos, ChunkPos chunkpos1) throws CommandSyntaxException {
+- if (ChunkPos.rangeClosed(chunkpos, chunkpos1).filter((chunkpos2) -> {
+- return !serverlevel.isLoaded(chunkpos2.getWorldPosition());
++ private static void checkLoaded(ServerLevel level, ChunkPos start, ChunkPos end) throws CommandSyntaxException {
++ if (ChunkPos.rangeClosed(start, end).filter((chunkcoordintpair2) -> {
++ return !level.isLoaded(chunkcoordintpair2.getWorldPosition());
+ }).findAny().isPresent()) {
+ throw BlockPosArgument.ERROR_NOT_LOADED.create();
+ }