Actually use extended/ambient in BeaconEffectEvent (#5647)

This commit is contained in:
Jake Potrebic 2021-05-18 01:43:46 -07:00 committed by GitHub
parent 979135878c
commit 22399b07f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add BeaconEffectEvent
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java
index c6914c8d2a3d1057c98537a3538097d3ac6149e0..f9b1ab0e19ff398a16b1452e86f1a165a4b54219 100644
index c6914c8d2a3d1057c98537a3538097d3ac6149e0..4098357d60165a4c670a7bc5134abf66178124c6 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java
@@ -42,6 +42,11 @@ import net.minecraft.world.phys.AxisAlignedBB;
@ -20,7 +20,7 @@ index c6914c8d2a3d1057c98537a3538097d3ac6149e0..f9b1ab0e19ff398a16b1452e86f1a165
public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable {
@@ -268,14 +273,31 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
@@ -268,14 +273,30 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
}
private void applyEffect(List list, MobEffectList effects, int i, int b0) {
@ -47,13 +47,12 @@ index c6914c8d2a3d1057c98537a3538097d3ac6149e0..f9b1ab0e19ff398a16b1452e86f1a165
+ // Paper start - BeaconEffectEvent
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) entityhuman.getBukkitEntity(), isPrimary);
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ PotionEffect eventEffect = event.getEffect();
+ entityhuman.addEffect(new MobEffect(MobEffectList.fromId(eventEffect.getType().getId()), eventEffect.getDuration(), eventEffect.getAmplifier(), true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+ entityhuman.addEffect(new MobEffect(CraftPotionUtil.fromBukkit(event.getEffect())), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+ // Paper end
}
}
}
@@ -298,10 +320,10 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
@@ -298,10 +319,10 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
int i = getLevel();
List list = getHumansInRange();

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Beacon API - custom effect ranges
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java
index f9b1ab0e19ff398a16b1452e86f1a165a4b54219..8dfb9eb12d07c2d4737ecf3de1ae7f6de31891bf 100644
index 4098357d60165a4c670a7bc5134abf66178124c6..cd28a731a56eb7534faae5b120195b62d5d15bd4 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBeacon.java
@@ -73,6 +73,26 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
@ -45,7 +45,7 @@ index f9b1ab0e19ff398a16b1452e86f1a165a4b54219..8dfb9eb12d07c2d4737ecf3de1ae7f6d
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(this.position)).g(d0).b(0.0D, (double) this.world.getBuildHeight(), 0.0D);
List<EntityHuman> list = this.world.a(EntityHuman.class, axisalignedbb);
@@ -364,6 +385,9 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
@@ -363,6 +384,9 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available
// CraftBukkit end
@ -55,7 +55,7 @@ index f9b1ab0e19ff398a16b1452e86f1a165a4b54219..8dfb9eb12d07c2d4737ecf3de1ae7f6d
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
this.customName = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
}
@@ -380,6 +404,8 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
@@ -379,6 +403,8 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
if (this.customName != null) {
nbttagcompound.setString("CustomName", IChatBaseComponent.ChatSerializer.a(this.customName));
}