diff options
Diffstat (limited to 'Spigot-Server-Patches-Unmapped/0596-Beacon-API-custom-effect-ranges.patch')
-rw-r--r-- | Spigot-Server-Patches-Unmapped/0596-Beacon-API-custom-effect-ranges.patch | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/Spigot-Server-Patches-Unmapped/0596-Beacon-API-custom-effect-ranges.patch b/Spigot-Server-Patches-Unmapped/0596-Beacon-API-custom-effect-ranges.patch new file mode 100644 index 0000000000..f32bda9f01 --- /dev/null +++ b/Spigot-Server-Patches-Unmapped/0596-Beacon-API-custom-effect-ranges.patch @@ -0,0 +1,90 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <[email protected]> +Date: Wed, 24 Jun 2020 12:39:08 -0600 +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 +--- 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 + return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryEffect, getLevel(), getAmplification(), true, true)) : null; + } + // CraftBukkit end ++ // Paper start - add field/methods for custom range ++ private final String PAPER_RANGE_TAG = "Paper.Range"; ++ private double effectRange = -1; ++ ++ public double getEffectRange() { ++ if (this.effectRange < 0) { ++ return this.levels * 10 + 10; ++ } else { ++ return effectRange; ++ } ++ } ++ ++ public void setEffectRange(double range) { ++ this.effectRange = range; ++ } ++ ++ public void resetEffectRange() { ++ this.effectRange = -1; ++ } ++ // Paper end + + public TileEntityBeacon() { + super(TileEntityTypes.BEACON); +@@ -263,7 +283,8 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic + + public List getHumansInRange() { + { +- double d0 = (double) (this.levels * 10 + 10); ++ // Paper - custom beacon ranges ++ double d0 = this.getEffectRange(); + + 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 + this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary")); + this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available + // CraftBukkit end ++ // Paper ++ this.effectRange = nbttagcompound.hasKeyOfType(PAPER_RANGE_TAG, 6) ? nbttagcompound.getDouble(PAPER_RANGE_TAG) : -1; ++ + 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 + if (this.customName != null) { + nbttagcompound.setString("CustomName", IChatBaseComponent.ChatSerializer.a(this.customName)); + } ++ // Paper ++ nbttagcompound.setDouble(PAPER_RANGE_TAG, this.effectRange); + + this.chestLock.a(nbttagcompound); + return nbttagcompound; +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +index d3ae5cadd88f9012203d2c04cbe38af9b215ef0b..c2e054853cba891326d45e9129bbc09e32fa3cc7 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +@@ -108,4 +108,19 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme + public void setLock(String key) { + this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key); + } ++ ++ @Override ++ public double getEffectRange() { ++ return this.getSnapshot().getEffectRange(); ++ } ++ ++ @Override ++ public void setEffectRange(double range) { ++ this.getSnapshot().setEffectRange(range); ++ } ++ ++ @Override ++ public void resetEffectRange() { ++ this.getSnapshot().resetEffectRange(); ++ } + } |