3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 11:30:06 +01:00
Paper/Spigot-Server-Patches/0597-Beacon-API-custom-effect-ranges.patch
Josh Roy b31089a929
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5325)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
d264e972 #591: Add option for a consumer before spawning an item
1c537fce #590: Add spawn and transform reasons for piglin zombification.

CraftBukkit Changes:
ee5006d1 #810: Add option for a consumer before spawning an item
f6a39d3c #809: Add spawn and transform reasons for piglin zombification.
0c24068a Organise imports

Spigot Changes:
bff52619 Organise imports
2021-03-08 15:12:31 -08:00

91 Zeilen
3.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 24 Jun 2020 12:39:08 -0600
Subject: [PATCH] Beacon API - custom effect ranges
diff --git a/src/main/java/net/minecraft/server/TileEntityBeacon.java b/src/main/java/net/minecraft/server/TileEntityBeacon.java
index fdf73eca821bab5ec7a742645893793679b5d42c..9019db391bc98b55eaa8bef11ab78c9d88fa7a18 100644
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
@@ -43,6 +43,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);
@@ -233,7 +253,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);
@@ -334,6 +355,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"));
}
@@ -350,6 +374,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 252b03e287cbe9212c7ec80be049647c4c77d37a..939782a75258b2228a5566648ce5a4ec2cc3e76e 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();
+ }
}