diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/commands/SummonCommand.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/commands/SummonCommand.java.patch | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/commands/SummonCommand.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/commands/SummonCommand.java.patch new file mode 100644 index 0000000000..e25ba0fd60 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/commands/SummonCommand.java.patch @@ -0,0 +1,95 @@ +--- a/net/minecraft/server/commands/SummonCommand.java ++++ b/net/minecraft/server/commands/SummonCommand.java +@@ -7,7 +7,6 @@ + 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; +@@ -20,9 +19,9 @@ + 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.entity.SpawnGroupData; + import net.minecraft.world.level.Level; + import net.minecraft.world.phys.Vec3; + +@@ -34,41 +33,41 @@ + + public SummonCommand() {} + +- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher, CommandBuildContext commandbuildcontext) { +- commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("summon").requires((commandsourcestack) -> { +- return commandsourcestack.hasPermission(2); +- })).then(((RequiredArgumentBuilder) Commands.argument("entity", ResourceArgument.resource(commandbuildcontext, Registries.ENTITY_TYPE)).suggests(SuggestionProviders.SUMMONABLE_ENTITIES).executes((commandcontext) -> { ++ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) { ++ 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) Commands.argument("pos", Vec3Argument.vec3()).executes((commandcontext) -> { ++ })).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(Commands.argument("nbt", CompoundTagArgument.compoundTag()).executes((commandcontext) -> { ++ })).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 commandsourcestack, Holder.Reference<EntityType<?>> holder_reference, Vec3 vec3, CompoundTag compoundtag, boolean flag) throws CommandSyntaxException { +- BlockPos blockpos = BlockPos.containing(vec3); ++ public static Entity createEntity(CommandSourceStack source, Holder.Reference<EntityType<?>> type, Vec3 pos, CompoundTag tag, boolean randomizeProperties) throws CommandSyntaxException { ++ BlockPos blockposition = BlockPos.containing(pos); + +- if (!Level.isInSpawnableBounds(blockpos)) { ++ if (!Level.isInSpawnableBounds(blockposition)) { + throw SummonCommand.INVALID_POSITION.create(); + } else { +- CompoundTag compoundtag1 = compoundtag.copy(); ++ CompoundTag nbttagcompound1 = tag.copy(); + +- compoundtag1.putString("id", holder_reference.key().location().toString()); +- ServerLevel serverlevel = commandsourcestack.getLevel(); +- Entity entity = EntityType.loadEntityRecursive(compoundtag1, serverlevel, (entity1) -> { +- entity1.moveTo(vec3.x, vec3.y, vec3.z, entity1.getYRot(), entity1.getXRot()); ++ 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 SummonCommand.ERROR_FAILED.create(); + } else { +- if (flag && entity instanceof Mob) { +- ((Mob) entity).finalizeSpawn(commandsourcestack.getLevel(), commandsourcestack.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData) null, (CompoundTag) null); ++ if (randomizeProperties && entity instanceof Mob) { ++ ((Mob) entity).finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (CompoundTag) null); + } + +- if (!serverlevel.tryAddFreshEntityWithPassengers(entity)) { ++ 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; +@@ -77,10 +76,10 @@ + } + } + +- private static int spawnEntity(CommandSourceStack commandsourcestack, Holder.Reference<EntityType<?>> holder_reference, Vec3 vec3, CompoundTag compoundtag, boolean flag) throws CommandSyntaxException { +- Entity entity = createEntity(commandsourcestack, holder_reference, vec3, compoundtag, flag); ++ 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); + +- commandsourcestack.sendSuccess(() -> { ++ source.sendSuccess(() -> { + return Component.translatable("commands.summon.success", entity.getDisplayName()); + }, true); + return 1; |