From 52d26db5a0345a2e5e575fcececb4727fdcb5107 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Sat, 14 Dec 2024 18:27:10 +0100 Subject: [PATCH] net.minecraft.world.item.consume_effects --- ...ApplyStatusEffectsConsumeEffect.java.patch | 19 +++++++++++ ...arAllStatusEffectsConsumeEffect.java.patch | 14 ++++++++ .../consume_effects/ConsumeEffect.java.patch | 19 +++++++++++ ...emoveStatusEffectsConsumeEffect.java.patch | 16 ++++++++++ .../TeleportRandomlyConsumeEffect.java.patch | 17 ++++++++++ ...ApplyStatusEffectsConsumeEffect.java.patch | 32 ------------------- ...arAllStatusEffectsConsumeEffect.java.patch | 24 -------------- .../consume_effects/ConsumeEffect.java.patch | 30 ----------------- ...emoveStatusEffectsConsumeEffect.java.patch | 29 ----------------- .../TeleportRandomlyConsumeEffect.java.patch | 20 ------------ 10 files changed, 85 insertions(+), 135 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch new file mode 100644 index 0000000000..4d29a75fd9 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java +@@ -46,14 +_,14 @@ + } + + @Override +- public boolean apply(Level level, ItemStack stack, LivingEntity entity) { ++ public boolean apply(Level level, ItemStack stack, LivingEntity entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) { // CraftBukkit + if (entity.getRandom().nextFloat() >= this.probability) { + return false; + } else { + boolean flag = false; + + for (MobEffectInstance mobEffectInstance : this.effects) { +- if (entity.addEffect(new MobEffectInstance(mobEffectInstance))) { ++ if (entity.addEffect(new MobEffectInstance(mobEffectInstance), cause)) { // CraftBukkit + flag = true; + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch new file mode 100644 index 0000000000..37064488ba --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java +@@ -18,7 +_,9 @@ + } + + @Override +- public boolean apply(Level level, ItemStack stack, LivingEntity entity) { +- return entity.removeAllEffects(); ++ // CraftBukkit start ++ public boolean apply(Level level, ItemStack stack, LivingEntity entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) { ++ return entity.removeAllEffects(cause); ++ // CraftBukkit end + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch new file mode 100644 index 0000000000..af59bc597a --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/item/consume_effects/ConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/ConsumeEffect.java +@@ -19,7 +_,15 @@ + + ConsumeEffect.Type getType(); + +- boolean apply(Level level, ItemStack stack, LivingEntity entity); ++ // CraftBukkit start ++ default boolean apply(Level level, ItemStack stack, LivingEntity entity) { ++ return this.apply(level, stack, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); ++ } ++ ++ default boolean apply(Level level, ItemStack stack, LivingEntity entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) { ++ return this.apply(level, stack, entity); ++ } ++ // CraftBukkit end + + public record Type(MapCodec codec, StreamCodec streamCodec) { + public static final ConsumeEffect.Type APPLY_EFFECTS = register( diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch new file mode 100644 index 0000000000..9cd988de23 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java +@@ -35,11 +_,11 @@ + } + + @Override +- public boolean apply(Level level, ItemStack stack, LivingEntity entity) { ++ public boolean apply(Level level, ItemStack stack, LivingEntity entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) { // CraftBukkit + boolean flag = false; + + for (Holder holder : this.effects) { +- if (entity.removeEffect(holder)) { ++ if (entity.removeEffect(holder, cause)) { // CraftBukkit + flag = true; + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch new file mode 100644 index 0000000000..9a43ef7d58 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java +@@ -55,7 +_,13 @@ + } + + Vec3 vec3 = entity.position(); +- if (entity.randomTeleport(d, d1, d2, true)) { ++ // CraftBukkit start - handle canceled status of teleport event ++ java.util.Optional status = entity.randomTeleport(d, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); ++ ++ // teleport event was canceled, no more tries ++ if (!status.isPresent()) break; ++ if (status.get()) { ++ // CraftBukkit end + level.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(entity)); + SoundSource soundSource; + SoundEvent soundEvent; diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch deleted file mode 100644 index 2551be5478..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java -+++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java -@@ -12,6 +12,9 @@ - import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import org.bukkit.event.entity.EntityPotionEffectEvent; -+// CraftBukkit end - - public record ApplyStatusEffectsConsumeEffect(List effects, float probability) implements ConsumeEffect { - -@@ -38,8 +41,8 @@ - } - - @Override -- public boolean apply(Level world, ItemStack stack, LivingEntity user) { -- if (user.getRandom().nextFloat() >= this.probability) { -+ public boolean apply(Level world, ItemStack itemstack, LivingEntity entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit -+ if (entityliving.getRandom().nextFloat() >= this.probability) { - return false; - } else { - boolean flag = false; -@@ -48,7 +51,7 @@ - while (iterator.hasNext()) { - MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); - -- if (user.addEffect(new MobEffectInstance(mobeffect))) { -+ if (entityliving.addEffect(new MobEffectInstance(mobeffect), cause)) { // CraftBukkit - flag = true; - } - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch deleted file mode 100644 index 35168c5339..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java -+++ b/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java -@@ -6,6 +6,9 @@ - import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import org.bukkit.event.entity.EntityPotionEffectEvent; -+// CraftBukkit end - - public record ClearAllStatusEffectsConsumeEffect() implements ConsumeEffect { - -@@ -19,7 +22,9 @@ - } - - @Override -- public boolean apply(Level world, ItemStack stack, LivingEntity user) { -- return user.removeAllEffects(); -+ // CraftBukkit start -+ public boolean apply(Level world, ItemStack itemstack, LivingEntity entityliving, EntityPotionEffectEvent.Cause cause) { -+ return entityliving.removeAllEffects(cause); -+ // CraftBukkit end - } - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch deleted file mode 100644 index c5d56842c7..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/minecraft/world/item/consume_effects/ConsumeEffect.java -+++ b/net/minecraft/world/item/consume_effects/ConsumeEffect.java -@@ -11,6 +11,9 @@ - import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import org.bukkit.event.entity.EntityPotionEffectEvent; -+// CraftBukkit end - - public interface ConsumeEffect { - -@@ -19,8 +22,16 @@ - - ConsumeEffect.Type getType(); - -- boolean apply(Level world, ItemStack stack, LivingEntity user); -+ // CraftBukkit start -+ default boolean apply(Level world, ItemStack stack, LivingEntity user) { -+ return this.apply(world, stack, user, EntityPotionEffectEvent.Cause.UNKNOWN); -+ } - -+ default boolean apply(Level world, ItemStack itemstack, LivingEntity entityliving, EntityPotionEffectEvent.Cause cause) { -+ return this.apply(world, itemstack, entityliving); -+ } -+ // CraftBukkit end -+ - public static record Type(MapCodec codec, StreamCodec streamCodec) { - - public static final ConsumeEffect.Type APPLY_EFFECTS = register("apply_effects", ApplyStatusEffectsConsumeEffect.CODEC, ApplyStatusEffectsConsumeEffect.STREAM_CODEC); diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch deleted file mode 100644 index c5eacaef69..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java -+++ b/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java -@@ -14,6 +14,9 @@ - import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import org.bukkit.event.entity.EntityPotionEffectEvent; -+// CraftBukkit end - - public record RemoveStatusEffectsConsumeEffect(HolderSet effects) implements ConsumeEffect { - -@@ -32,14 +35,14 @@ - } - - @Override -- public boolean apply(Level world, ItemStack stack, LivingEntity user) { -+ public boolean apply(Level world, ItemStack itemstack, LivingEntity entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit - boolean flag = false; - Iterator iterator = this.effects.iterator(); - - while (iterator.hasNext()) { - Holder holder = (Holder) iterator.next(); - -- if (user.removeEffect(holder)) { -+ if (entityliving.removeEffect(holder, cause)) { // CraftBukkit - flag = true; - } - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch deleted file mode 100644 index b419363bd1..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java -+++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java -@@ -53,7 +53,16 @@ - - Vec3 vec3d = user.position(); - -- if (user.randomTeleport(d0, d1, d2, true)) { -+ // CraftBukkit start - handle canceled status of teleport event -+ java.util.Optional status = user.randomTeleport(d0, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); -+ -+ if (!status.isPresent()) { -+ // teleport event was canceled, no more tries -+ break; -+ } -+ -+ if (status.get()) { -+ // CraftBukkit end - world.gameEvent((Holder) GameEvent.TELEPORT, vec3d, GameEvent.Context.of((Entity) user)); - SoundEvent soundeffect; - SoundSource soundcategory;