testserver/Unmapped-Spigot-Server-Patches/0039-Add-BeaconEffectEvent....

68 lines
3.1 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2016-02-29 23:09:49 +00:00
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 23:30:53 -0600
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..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;
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
2016-07-27 00:30:03 +00:00
import org.bukkit.potion.PotionEffect;
2016-02-29 23:09:49 +00:00
// CraftBukkit end
+// Paper start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Player;
+import com.destroystokyo.paper.event.block.BeaconEffectEvent;
+// Paper end
2019-04-25 06:53:51 +00:00
public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable {
@@ -268,14 +273,30 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
2016-07-27 00:30:03 +00:00
}
private void applyEffect(List list, MobEffectList effects, int i, int b0) {
+ // Paper - BeaconEffectEvent
+ applyEffect(list, effects, i, b0, true);
+ }
+
+ private void applyEffect(List list, MobEffectList effects, int i, int b0, boolean isPrimary) {
+ // Paper - BeaconEffectEvent
{
Iterator iterator = list.iterator();
2016-02-29 23:09:49 +00:00
EntityHuman entityhuman;
2016-07-27 00:30:03 +00:00
+ // Paper start - BeaconEffectEvent
2016-02-29 23:09:49 +00:00
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
2016-07-27 00:30:03 +00:00
+ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffect(effects, i, b0, true, true));
2016-02-29 23:09:49 +00:00
+ // Paper end
+
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
2018-07-20 19:57:43 +00:00
- entityhuman.addEffect(new MobEffect(effects, i, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+
2016-02-29 23:09:49 +00:00
+ // Paper start - BeaconEffectEvent
2016-07-27 00:30:03 +00:00
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) entityhuman.getBukkitEntity(), isPrimary);
2016-02-29 23:09:49 +00:00
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ entityhuman.addEffect(new MobEffect(CraftPotionUtil.fromBukkit(event.getEffect())), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
2016-02-29 23:09:49 +00:00
+ // Paper end
}
2016-07-27 00:30:03 +00:00
}
}
@@ -298,10 +319,10 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
2016-07-27 00:30:03 +00:00
int i = getLevel();
List list = getHumansInRange();
2016-02-29 23:09:49 +00:00
2016-11-17 02:23:38 +00:00
- applyEffect(list, this.primaryEffect, i, b0);
+ applyEffect(list, this.primaryEffect, i, b0, true); // Paper - BeaconEffectEvent
2016-02-29 23:09:49 +00:00
2016-07-27 00:30:03 +00:00
if (hasSecondaryEffect()) {
2016-11-17 02:23:38 +00:00
- applyEffect(list, this.secondaryEffect, i, 0);
+ applyEffect(list, this.secondaryEffect, i, 0, false); // Paper - BeaconEffectEvent
2016-02-29 23:09:49 +00:00
}
}
2016-07-27 00:30:03 +00:00