2019-07-20 06:01:24 +02:00
|
|
|
From d2e4d23521f1cc249c8ac8f6a5cc93c5c83240db Mon Sep 17 00:00:00 2001
|
2016-03-01 00:09:49 +01: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/server/TileEntityBeacon.java b/src/main/java/net/minecraft/server/TileEntityBeacon.java
|
2019-07-20 06:01:24 +02:00
|
|
|
index 69d59a9f88..e510234db5 100644
|
2016-03-01 00:09:49 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
|
2019-04-25 08:53:51 +02:00
|
|
|
@@ -14,6 +14,11 @@ import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
2016-07-27 02:30:03 +02:00
|
|
|
import org.bukkit.potion.PotionEffect;
|
2016-03-01 00:09:49 +01: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 08:53:51 +02:00
|
|
|
public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable {
|
|
|
|
|
2019-07-20 06:01:24 +02:00
|
|
|
@@ -242,14 +247,31 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
|
2016-07-27 02:30:03 +02: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-03-01 00:09:49 +01:00
|
|
|
|
|
|
|
EntityHuman entityhuman;
|
|
|
|
|
2016-07-27 02:30:03 +02:00
|
|
|
+ // Paper start - BeaconEffectEvent
|
2016-03-01 00:09:49 +01:00
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
|
2016-07-27 02:30:03 +02:00
|
|
|
+ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffect(effects, i, b0, true, true));
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
entityhuman = (EntityHuman) iterator.next();
|
2018-07-20 21:57:43 +02:00
|
|
|
- entityhuman.addEffect(new MobEffect(effects, i, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
|
|
|
|
+
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper start - BeaconEffectEvent
|
2016-07-27 02:30:03 +02:00
|
|
|
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) entityhuman.getBukkitEntity(), isPrimary);
|
2016-03-01 00:09:49 +01:00
|
|
|
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
|
2016-07-27 02:30:03 +02:00
|
|
|
+ PotionEffect eventEffect = event.getEffect();
|
2018-07-20 21:57:43 +02:00
|
|
|
+ entityhuman.addEffect(new MobEffect(MobEffectList.fromId(eventEffect.getType().getId()), eventEffect.getDuration(), eventEffect.getAmplifier(), true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper end
|
|
|
|
}
|
2016-07-27 02:30:03 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-20 06:01:24 +02:00
|
|
|
@@ -272,10 +294,10 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
|
2016-07-27 02:30:03 +02:00
|
|
|
int i = getLevel();
|
|
|
|
List list = getHumansInRange();
|
2016-03-01 00:09:49 +01:00
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
- applyEffect(list, this.primaryEffect, i, b0);
|
|
|
|
+ applyEffect(list, this.primaryEffect, i, b0, true); // Paper - BeaconEffectEvent
|
2016-03-01 00:09:49 +01:00
|
|
|
|
2016-07-27 02:30:03 +02:00
|
|
|
if (hasSecondaryEffect()) {
|
2016-11-17 03:23:38 +01:00
|
|
|
- applyEffect(list, this.secondaryEffect, i, 0);
|
|
|
|
+ applyEffect(list, this.secondaryEffect, i, 0, false); // Paper - BeaconEffectEvent
|
2016-03-01 00:09:49 +01:00
|
|
|
}
|
|
|
|
}
|
2016-07-27 02:30:03 +02:00
|
|
|
|
2016-03-01 00:09:49 +01:00
|
|
|
--
|
2019-07-20 06:01:24 +02:00
|
|
|
2.22.0
|
2016-03-01 00:09:49 +01:00
|
|
|
|