@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java
|
||||
@@ -13,6 +13,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record ApplyStatusEffectsConsumeEffect(List<MobEffect> effects, float probability) implements ConsumeEffect {
|
||||
|
||||
public static final MapCodec<ApplyStatusEffectsConsumeEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
@@ -38,7 +42,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
+ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit
|
||||
if (entityliving.getRandom().nextFloat() >= this.probability) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -48,7 +52,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffect mobeffect = (MobEffect) iterator.next();
|
||||
|
||||
- if (entityliving.addEffect(new MobEffect(mobeffect))) {
|
||||
+ if (entityliving.addEffect(new MobEffect(mobeffect), cause)) { // CraftBukkit
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java
|
||||
@@ -7,6 +7,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record ClearAllStatusEffectsConsumeEffect() implements ConsumeEffect {
|
||||
|
||||
public static final ClearAllStatusEffectsConsumeEffect INSTANCE = new ClearAllStatusEffectsConsumeEffect();
|
||||
@@ -19,7 +23,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
- return entityliving.removeAllEffects();
|
||||
+ // CraftBukkit start
|
||||
+ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) {
|
||||
+ return entityliving.removeAllEffects(cause);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/ConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/ConsumeEffect.java
|
||||
@@ -12,6 +12,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public interface ConsumeEffect {
|
||||
|
||||
Codec<ConsumeEffect> CODEC = BuiltInRegistries.CONSUME_EFFECT_TYPE.byNameCodec().dispatch(ConsumeEffect::getType, ConsumeEffect.a::codec);
|
||||
@@ -19,7 +23,15 @@
|
||||
|
||||
ConsumeEffect.a<? extends ConsumeEffect> getType();
|
||||
|
||||
- boolean apply(World world, ItemStack itemstack, EntityLiving entityliving);
|
||||
+ // CraftBukkit start
|
||||
+ default boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
+ return this.apply(world, itemstack, entityliving, EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ default boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) {
|
||||
+ return this.apply(world, itemstack, entityliving);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static record a<T extends ConsumeEffect>(MapCodec<T> codec, StreamCodec<RegistryFriendlyByteBuf, T> streamCodec) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java
|
||||
@@ -15,6 +15,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record RemoveStatusEffectsConsumeEffect(HolderSet<MobEffectList> effects) implements ConsumeEffect {
|
||||
|
||||
public static final MapCodec<RemoveStatusEffectsConsumeEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
@@ -32,14 +36,14 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
+ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit
|
||||
boolean flag = false;
|
||||
Iterator iterator = this.effects.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Holder<MobEffectList> holder = (Holder) iterator.next();
|
||||
|
||||
- if (entityliving.removeEffect(holder)) {
|
||||
+ if (entityliving.removeEffect(holder, cause)) { // CraftBukkit
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java
|
||||
@@ -53,7 +53,16 @@
|
||||
|
||||
Vec3D vec3d = entityliving.position();
|
||||
|
||||
- if (entityliving.randomTeleport(d0, d1, d2, true)) {
|
||||
+ // CraftBukkit start - handle canceled status of teleport event
|
||||
+ java.util.Optional<Boolean> status = entityliving.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.a.of((Entity) entityliving));
|
||||
SoundEffect soundeffect;
|
||||
SoundCategory soundcategory;
|
||||
Reference in New Issue
Block a user