diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/commands/SummonCommand.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/server/commands/SummonCommand.java.patch | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/commands/SummonCommand.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/commands/SummonCommand.java.patch new file mode 100644 index 0000000000..fb70452a26 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/server/commands/SummonCommand.java.patch @@ -0,0 +1,140 @@ +--- a/net/minecraft/server/commands/SummonCommand.java ++++ b/net/minecraft/server/commands/SummonCommand.java +@@ -1,12 +1,12 @@ + package net.minecraft.server.commands; + + import com.mojang.brigadier.CommandDispatcher; +-import com.mojang.brigadier.context.CommandContext; ++import com.mojang.brigadier.builder.LiteralArgumentBuilder; ++import com.mojang.brigadier.builder.RequiredArgumentBuilder; + import com.mojang.brigadier.exceptions.CommandSyntaxException; + import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; + import net.minecraft.commands.CommandBuildContext; + import net.minecraft.commands.CommandSourceStack; +-import net.minecraft.commands.Commands; + import net.minecraft.commands.arguments.CompoundTagArgument; + import net.minecraft.commands.arguments.ResourceArgument; + import net.minecraft.commands.arguments.coordinates.Vec3Argument; +@@ -19,82 +19,56 @@ + import net.minecraft.server.level.ServerLevel; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EnumMobSpawn; ++import net.minecraft.world.entity.GroupDataEntity; + import net.minecraft.world.entity.Mob; +-import net.minecraft.world.entity.MobSpawnType; + import net.minecraft.world.level.Level; + import net.minecraft.world.phys.Vec3; + + public class SummonCommand { ++ + private static final SimpleCommandExceptionType ERROR_FAILED = new SimpleCommandExceptionType(Component.translatable("commands.summon.failed")); + private static final SimpleCommandExceptionType ERROR_DUPLICATE_UUID = new SimpleCommandExceptionType(Component.translatable("commands.summon.failed.uuid")); + private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(Component.translatable("commands.summon.invalidPosition")); + ++ public SummonCommand() {} ++ + public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) { +- dispatcher.register( +- Commands.literal("summon") +- .requires(source -> source.hasPermission(2)) +- .then( +- Commands.argument("entity", ResourceArgument.resource(context, Registries.ENTITY_TYPE)) +- .suggests(SuggestionProviders.SUMMONABLE_ENTITIES) +- .executes( +- context1 -> spawnEntity( +- context1.getSource(), +- ResourceArgument.getSummonableEntityType(context1, "entity"), +- context1.getSource().getPosition(), +- new CompoundTag(), +- true +- ) +- ) +- .then( +- Commands.argument("pos", Vec3Argument.vec3()) +- .executes( +- context1 -> spawnEntity( +- context1.getSource(), +- ResourceArgument.getSummonableEntityType(context1, "entity"), +- Vec3Argument.getVec3(context1, "pos"), +- new CompoundTag(), +- true +- ) +- ) +- .then( +- Commands.argument("nbt", CompoundTagArgument.compoundTag()) +- .executes( +- context1 -> spawnEntity( +- context1.getSource(), +- ResourceArgument.getSummonableEntityType(context1, "entity"), +- Vec3Argument.getVec3(context1, "pos"), +- CompoundTagArgument.getCompoundTag(context1, "nbt"), +- false +- ) +- ) +- ) +- ) +- ) +- ); ++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("summon").requires((commandlistenerwrapper) -> { ++ return commandlistenerwrapper.hasPermission(2); ++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("entity", ResourceArgument.resource(context, Registries.ENTITY_TYPE)).suggests(SuggestionProviders.SUMMONABLE_ENTITIES).executes((commandcontext) -> { ++ return spawnEntity((CommandSourceStack) commandcontext.getSource(), ResourceArgument.getSummonableEntityType(commandcontext, "entity"), ((CommandSourceStack) commandcontext.getSource()).getPosition(), new CompoundTag(), true); ++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("pos", Vec3Argument.vec3()).executes((commandcontext) -> { ++ return spawnEntity((CommandSourceStack) commandcontext.getSource(), ResourceArgument.getSummonableEntityType(commandcontext, "entity"), Vec3Argument.getVec3(commandcontext, "pos"), new CompoundTag(), true); ++ })).then(net.minecraft.commands.Commands.argument("nbt", CompoundTagArgument.compoundTag()).executes((commandcontext) -> { ++ return spawnEntity((CommandSourceStack) commandcontext.getSource(), ResourceArgument.getSummonableEntityType(commandcontext, "entity"), Vec3Argument.getVec3(commandcontext, "pos"), CompoundTagArgument.getCompoundTag(commandcontext, "nbt"), false); ++ }))))); + } + + public static Entity createEntity(CommandSourceStack source, Holder.Reference<EntityType<?>> type, Vec3 pos, CompoundTag tag, boolean randomizeProperties) throws CommandSyntaxException { +- BlockPos blockPos = BlockPos.containing(pos); +- if (!Level.isInSpawnableBounds(blockPos)) { +- throw INVALID_POSITION.create(); ++ BlockPos blockposition = BlockPos.containing(pos); ++ ++ if (!Level.isInSpawnableBounds(blockposition)) { ++ throw SummonCommand.INVALID_POSITION.create(); + } else { +- CompoundTag compoundTag = tag.copy(); +- compoundTag.putString("id", type.key().location().toString()); +- ServerLevel level = source.getLevel(); +- Entity entity = EntityType.loadEntityRecursive(compoundTag, level, entity1 -> { ++ CompoundTag nbttagcompound1 = tag.copy(); ++ ++ nbttagcompound1.putString("id", type.key().location().toString()); ++ ServerLevel worldserver = source.getLevel(); ++ Entity entity = EntityType.loadEntityRecursive(nbttagcompound1, worldserver, (entity1) -> { + entity1.moveTo(pos.x, pos.y, pos.z, entity1.getYRot(), entity1.getXRot()); + return entity1; + }); ++ + if (entity == null) { +- throw ERROR_FAILED.create(); ++ throw SummonCommand.ERROR_FAILED.create(); + } else { + if (randomizeProperties && entity instanceof Mob) { +- ((Mob)entity) +- .finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, null, null); ++ ((Mob) entity).finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (CompoundTag) null); + } + +- if (!level.tryAddFreshEntityWithPassengers(entity)) { +- throw ERROR_DUPLICATE_UUID.create(); ++ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND" ++ throw SummonCommand.ERROR_DUPLICATE_UUID.create(); + } else { + return entity; + } +@@ -104,7 +78,10 @@ + + private static int spawnEntity(CommandSourceStack source, Holder.Reference<EntityType<?>> type, Vec3 pos, CompoundTag tag, boolean randomizeProperties) throws CommandSyntaxException { + Entity entity = createEntity(source, type, pos, tag, randomizeProperties); +- source.sendSuccess(() -> Component.translatable("commands.summon.success", entity.getDisplayName()), true); ++ ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.summon.success", entity.getDisplayName()); ++ }, true); + return 1; + } + } |