diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/commands/EffectCommands.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/server/commands/EffectCommands.java.patch | 344 |
1 files changed, 344 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/commands/EffectCommands.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/commands/EffectCommands.java.patch new file mode 100644 index 0000000000..155d6ee789 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/server/commands/EffectCommands.java.patch @@ -0,0 +1,344 @@ +--- a/net/minecraft/server/commands/EffectCommands.java ++++ b/net/minecraft/server/commands/EffectCommands.java +@@ -4,14 +4,15 @@ + import com.mojang.brigadier.CommandDispatcher; + import com.mojang.brigadier.arguments.BoolArgumentType; + import com.mojang.brigadier.arguments.IntegerArgumentType; +-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 java.util.Collection; ++import java.util.Iterator; + import javax.annotation.Nullable; + 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.ResourceArgument; + import net.minecraft.core.Holder; +@@ -23,208 +24,112 @@ + import net.minecraft.world.entity.LivingEntity; + + public class EffectCommands { ++ + private static final SimpleCommandExceptionType ERROR_GIVE_FAILED = new SimpleCommandExceptionType(Component.translatable("commands.effect.give.failed")); +- private static final SimpleCommandExceptionType ERROR_CLEAR_EVERYTHING_FAILED = new SimpleCommandExceptionType( +- Component.translatable("commands.effect.clear.everything.failed") +- ); +- private static final SimpleCommandExceptionType ERROR_CLEAR_SPECIFIC_FAILED = new SimpleCommandExceptionType( +- Component.translatable("commands.effect.clear.specific.failed") +- ); ++ private static final SimpleCommandExceptionType ERROR_CLEAR_EVERYTHING_FAILED = new SimpleCommandExceptionType(Component.translatable("commands.effect.clear.everything.failed")); ++ private static final SimpleCommandExceptionType ERROR_CLEAR_SPECIFIC_FAILED = new SimpleCommandExceptionType(Component.translatable("commands.effect.clear.specific.failed")); + ++ public EffectCommands() {} ++ + public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) { +- dispatcher.register( +- Commands.literal("effect") +- .requires(source -> source.hasPermission(2)) +- .then( +- Commands.literal("clear") +- .executes(context1 -> clearEffects(context1.getSource(), ImmutableList.of(context1.getSource().getEntityOrException()))) +- .then( +- Commands.argument("targets", EntityArgument.entities()) +- .executes(context1 -> clearEffects(context1.getSource(), EntityArgument.getEntities(context1, "targets"))) +- .then( +- Commands.argument("effect", ResourceArgument.resource(context, Registries.MOB_EFFECT)) +- .executes( +- context1 -> clearEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect") +- ) +- ) +- ) +- ) +- ) +- .then( +- Commands.literal("give") +- .then( +- Commands.argument("targets", EntityArgument.entities()) +- .then( +- Commands.argument("effect", ResourceArgument.resource(context, Registries.MOB_EFFECT)) +- .executes( +- context1 -> giveEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect"), +- null, +- 0, +- true +- ) +- ) +- .then( +- Commands.argument("seconds", IntegerArgumentType.integer(1, 1000000)) +- .executes( +- context1 -> giveEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect"), +- IntegerArgumentType.getInteger(context1, "seconds"), +- 0, +- true +- ) +- ) +- .then( +- Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)) +- .executes( +- context1 -> giveEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect"), +- IntegerArgumentType.getInteger(context1, "seconds"), +- IntegerArgumentType.getInteger(context1, "amplifier"), +- true +- ) +- ) +- .then( +- Commands.argument("hideParticles", BoolArgumentType.bool()) +- .executes( +- context1 -> giveEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect"), +- IntegerArgumentType.getInteger(context1, "seconds"), +- IntegerArgumentType.getInteger(context1, "amplifier"), +- !BoolArgumentType.getBool(context1, "hideParticles") +- ) +- ) +- ) +- ) +- ) +- .then( +- Commands.literal("infinite") +- .executes( +- context1 -> giveEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect"), +- -1, +- 0, +- true +- ) +- ) +- .then( +- Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)) +- .executes( +- context1 -> giveEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect"), +- -1, +- IntegerArgumentType.getInteger(context1, "amplifier"), +- true +- ) +- ) +- .then( +- Commands.argument("hideParticles", BoolArgumentType.bool()) +- .executes( +- context1 -> giveEffect( +- context1.getSource(), +- EntityArgument.getEntities(context1, "targets"), +- ResourceArgument.getMobEffect(context1, "effect"), +- -1, +- IntegerArgumentType.getInteger(context1, "amplifier"), +- !BoolArgumentType.getBool(context1, "hideParticles") +- ) +- ) +- ) +- ) +- ) +- ) +- ) +- ) +- ); ++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("effect").requires((commandlistenerwrapper) -> { ++ return commandlistenerwrapper.hasPermission(2); ++ })).then(((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("clear").executes((commandcontext) -> { ++ return clearEffects((CommandSourceStack) commandcontext.getSource(), ImmutableList.of(((CommandSourceStack) commandcontext.getSource()).getEntityOrException())); ++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("targets", EntityArgument.entities()).executes((commandcontext) -> { ++ return clearEffects((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets")); ++ })).then(net.minecraft.commands.Commands.argument("effect", ResourceArgument.resource(context, Registries.MOB_EFFECT)).executes((commandcontext) -> { ++ return clearEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect")); ++ }))))).then(net.minecraft.commands.Commands.literal("give").then(net.minecraft.commands.Commands.argument("targets", EntityArgument.entities()).then(((RequiredArgumentBuilder) ((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("effect", ResourceArgument.resource(context, Registries.MOB_EFFECT)).executes((commandcontext) -> { ++ return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), (Integer) null, 0, true); ++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("seconds", IntegerArgumentType.integer(1, 1000000)).executes((commandcontext) -> { ++ return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), 0, true); ++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> { ++ return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), IntegerArgumentType.getInteger(commandcontext, "amplifier"), true); ++ })).then(net.minecraft.commands.Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> { ++ return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), IntegerArgumentType.getInteger(commandcontext, "amplifier"), !BoolArgumentType.getBool(commandcontext, "hideParticles")); ++ }))))).then(((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("infinite").executes((commandcontext) -> { ++ return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, 0, true); ++ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> { ++ return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, IntegerArgumentType.getInteger(commandcontext, "amplifier"), true); ++ })).then(net.minecraft.commands.Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> { ++ return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, IntegerArgumentType.getInteger(commandcontext, "amplifier"), !BoolArgumentType.getBool(commandcontext, "hideParticles")); ++ })))))))); + } + +- private static int giveEffect( +- CommandSourceStack source, +- Collection<? extends Entity> targets, +- Holder<MobEffect> effect, +- @Nullable Integer seconds, +- int amplifier, +- boolean showParticles +- ) throws CommandSyntaxException { +- MobEffect mobEffect = effect.value(); +- int i = 0; +- int i1; ++ private static int giveEffect(CommandSourceStack source, Collection<? extends Entity> targets, Holder<MobEffect> effect, @Nullable Integer seconds, int amplifier, boolean showParticles) throws CommandSyntaxException { ++ MobEffect mobeffectlist = (MobEffect) effect.value(); ++ int j = 0; ++ int k; ++ + if (seconds != null) { +- if (mobEffect.isInstantenous()) { +- i1 = seconds; ++ if (mobeffectlist.isInstantenous()) { ++ k = seconds; + } else if (seconds == -1) { +- i1 = -1; ++ k = -1; + } else { +- i1 = seconds * 20; ++ k = seconds * 20; + } +- } else if (mobEffect.isInstantenous()) { +- i1 = 1; ++ } else if (mobeffectlist.isInstantenous()) { ++ k = 1; + } else { +- i1 = 600; ++ k = 600; + } + +- for (Entity entity : targets) { ++ Iterator iterator = targets.iterator(); ++ ++ while (iterator.hasNext()) { ++ Entity entity = (Entity) iterator.next(); ++ + if (entity instanceof LivingEntity) { +- MobEffectInstance mobEffectInstance = new MobEffectInstance(mobEffect, i1, amplifier, false, showParticles); +- if (((LivingEntity)entity).addEffect(mobEffectInstance, source.getEntity())) { +- i++; ++ MobEffectInstance mobeffect = new MobEffectInstance(mobeffectlist, k, amplifier, false, showParticles); ++ ++ if (((LivingEntity) entity).addEffect(mobeffect, source.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++ ++j; + } + } + } + +- if (i == 0) { +- throw ERROR_GIVE_FAILED.create(); ++ if (j == 0) { ++ throw EffectCommands.ERROR_GIVE_FAILED.create(); + } else { + if (targets.size() == 1) { +- source.sendSuccess( +- () -> Component.translatable( +- "commands.effect.give.success.single", mobEffect.getDisplayName(), targets.iterator().next().getDisplayName(), i1 / 20 +- ), +- true +- ); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.effect.give.success.single", mobeffectlist.getDisplayName(), ((Entity) targets.iterator().next()).getDisplayName(), k / 20); ++ }, true); + } else { +- source.sendSuccess( +- () -> Component.translatable("commands.effect.give.success.multiple", mobEffect.getDisplayName(), targets.size(), i1 / 20), true +- ); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.effect.give.success.multiple", mobeffectlist.getDisplayName(), targets.size(), k / 20); ++ }, true); + } + +- return i; ++ return j; + } + } + + private static int clearEffects(CommandSourceStack source, Collection<? extends Entity> targets) throws CommandSyntaxException { + int i = 0; ++ Iterator iterator = targets.iterator(); + +- for (Entity entity : targets) { +- if (entity instanceof LivingEntity && ((LivingEntity)entity).removeAllEffects()) { +- i++; ++ while (iterator.hasNext()) { ++ Entity entity = (Entity) iterator.next(); ++ ++ if (entity instanceof LivingEntity && ((LivingEntity) entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++ ++i; + } + } + + if (i == 0) { +- throw ERROR_CLEAR_EVERYTHING_FAILED.create(); ++ throw EffectCommands.ERROR_CLEAR_EVERYTHING_FAILED.create(); + } else { + if (targets.size() == 1) { +- source.sendSuccess( +- () -> Component.translatable("commands.effect.clear.everything.success.single", targets.iterator().next().getDisplayName()), true +- ); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.effect.clear.everything.success.single", ((Entity) targets.iterator().next()).getDisplayName()); ++ }, true); + } else { +- source.sendSuccess(() -> Component.translatable("commands.effect.clear.everything.success.multiple", targets.size()), true); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.effect.clear.everything.success.multiple", targets.size()); ++ }, true); + } + + return i; +@@ -232,29 +137,29 @@ + } + + private static int clearEffect(CommandSourceStack source, Collection<? extends Entity> targets, Holder<MobEffect> effect) throws CommandSyntaxException { +- MobEffect mobEffect = effect.value(); ++ MobEffect mobeffectlist = (MobEffect) effect.value(); + int i = 0; ++ Iterator iterator = targets.iterator(); + +- for (Entity entity : targets) { +- if (entity instanceof LivingEntity && ((LivingEntity)entity).removeEffect(mobEffect)) { +- i++; ++ while (iterator.hasNext()) { ++ Entity entity = (Entity) iterator.next(); ++ ++ if (entity instanceof LivingEntity && ((LivingEntity) entity).removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++ ++i; + } + } + + if (i == 0) { +- throw ERROR_CLEAR_SPECIFIC_FAILED.create(); ++ throw EffectCommands.ERROR_CLEAR_SPECIFIC_FAILED.create(); + } else { + if (targets.size() == 1) { +- source.sendSuccess( +- () -> Component.translatable( +- "commands.effect.clear.specific.success.single", mobEffect.getDisplayName(), targets.iterator().next().getDisplayName() +- ), +- true +- ); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.effect.clear.specific.success.single", mobeffectlist.getDisplayName(), ((Entity) targets.iterator().next()).getDisplayName()); ++ }, true); + } else { +- source.sendSuccess( +- () -> Component.translatable("commands.effect.clear.specific.success.multiple", mobEffect.getDisplayName(), targets.size()), true +- ); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.effect.clear.specific.success.multiple", mobeffectlist.getDisplayName(), targets.size()); ++ }, true); + } + + return i; |