diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/commands/GiveCommand.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/commands/GiveCommand.java.patch | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/commands/GiveCommand.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/commands/GiveCommand.java.patch new file mode 100644 index 0000000000..bee7346024 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/commands/GiveCommand.java.patch @@ -0,0 +1,111 @@ +--- a/net/minecraft/server/commands/GiveCommand.java ++++ b/net/minecraft/server/commands/GiveCommand.java +@@ -9,7 +9,6 @@ + import java.util.Iterator; + import net.minecraft.commands.CommandBuildContext; + import net.minecraft.commands.CommandSourceStack; +-import net.minecraft.commands.Commands; + import net.minecraft.commands.arguments.EntityArgument; + import net.minecraft.commands.arguments.item.ItemArgument; + import net.minecraft.commands.arguments.item.ItemInput; +@@ -27,69 +26,69 @@ + + public GiveCommand() {} + +- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher, CommandBuildContext commandbuildcontext) { +- commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("give").requires((commandsourcestack) -> { +- return commandsourcestack.hasPermission(2); +- })).then(Commands.argument("targets", EntityArgument.players()).then(((RequiredArgumentBuilder) Commands.argument("item", ItemArgument.item(commandbuildcontext)).executes((commandcontext) -> { ++ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) { ++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("give").requires((commandlistenerwrapper) -> { ++ return commandlistenerwrapper.hasPermission(2); ++ })).then(net.minecraft.commands.Commands.argument("targets", EntityArgument.players()).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("item", ItemArgument.item(context)).executes((commandcontext) -> { + return giveItem((CommandSourceStack) commandcontext.getSource(), ItemArgument.getItem(commandcontext, "item"), EntityArgument.getPlayers(commandcontext, "targets"), 1); +- })).then(Commands.argument("count", IntegerArgumentType.integer(1)).executes((commandcontext) -> { ++ })).then(net.minecraft.commands.Commands.argument("count", IntegerArgumentType.integer(1)).executes((commandcontext) -> { + return giveItem((CommandSourceStack) commandcontext.getSource(), ItemArgument.getItem(commandcontext, "item"), EntityArgument.getPlayers(commandcontext, "targets"), IntegerArgumentType.getInteger(commandcontext, "count")); + }))))); + } + +- private static int giveItem(CommandSourceStack commandsourcestack, ItemInput iteminput, Collection<ServerPlayer> collection, int i) throws CommandSyntaxException { +- int j = iteminput.getItem().getMaxStackSize(); ++ private static int giveItem(CommandSourceStack source, ItemInput item, Collection<ServerPlayer> targets, int count) throws CommandSyntaxException { ++ int j = item.getItem().getMaxStackSize(); + int k = j * 100; +- ItemStack itemstack = iteminput.createItemStack(i, false); ++ ItemStack itemstack = item.createItemStack(count, false); + +- if (i > k) { +- commandsourcestack.sendFailure(Component.translatable("commands.give.failed.toomanyitems", k, itemstack.getDisplayName())); ++ if (count > k) { ++ source.sendFailure(Component.translatable("commands.give.failed.toomanyitems", k, itemstack.getDisplayName())); + return 0; + } else { +- Iterator iterator = collection.iterator(); ++ Iterator iterator = targets.iterator(); + + while (iterator.hasNext()) { +- ServerPlayer serverplayer = (ServerPlayer) iterator.next(); +- int l = i; ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ++ int l = count; + + while (l > 0) { + int i1 = Math.min(j, l); + + l -= i1; +- ItemStack itemstack1 = iteminput.createItemStack(i1, false); +- boolean flag = serverplayer.getInventory().add(itemstack1); +- ItemEntity itementity; ++ ItemStack itemstack1 = item.createItemStack(i1, false); ++ boolean flag = entityplayer.getInventory().add(itemstack1); ++ ItemEntity entityitem; + + if (flag && itemstack1.isEmpty()) { + itemstack1.setCount(1); +- itementity = serverplayer.drop(itemstack1, false); +- if (itementity != null) { +- itementity.makeFakeItem(); ++ entityitem = entityplayer.drop(itemstack1, false, false, false); // SPIGOT-2942: Add boolean to call event ++ if (entityitem != null) { ++ entityitem.makeFakeItem(); + } + +- serverplayer.level().playSound((Player) null, serverplayer.getX(), serverplayer.getY(), serverplayer.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, 0.2F, ((serverplayer.getRandom().nextFloat() - serverplayer.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F); +- serverplayer.containerMenu.broadcastChanges(); ++ entityplayer.level().playSound((Player) null, entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, 0.2F, ((entityplayer.getRandom().nextFloat() - entityplayer.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F); ++ entityplayer.containerMenu.broadcastChanges(); + } else { +- itementity = serverplayer.drop(itemstack1, false); +- if (itementity != null) { +- itementity.setNoPickUpDelay(); +- itementity.setTarget(serverplayer.getUUID()); ++ entityitem = entityplayer.drop(itemstack1, false); ++ if (entityitem != null) { ++ entityitem.setNoPickUpDelay(); ++ entityitem.setTarget(entityplayer.getUUID()); + } + } + } + } + +- if (collection.size() == 1) { +- commandsourcestack.sendSuccess(() -> { +- return Component.translatable("commands.give.success.single", i, itemstack.getDisplayName(), ((ServerPlayer) collection.iterator().next()).getDisplayName()); ++ if (targets.size() == 1) { ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.give.success.single", count, itemstack.getDisplayName(), ((ServerPlayer) targets.iterator().next()).getDisplayName()); + }, true); + } else { +- commandsourcestack.sendSuccess(() -> { +- return Component.translatable("commands.give.success.single", i, itemstack.getDisplayName(), collection.size()); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.give.success.single", count, itemstack.getDisplayName(), targets.size()); + }, true); + } + +- return collection.size(); ++ return targets.size(); + } + } + } |