mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-03 01:10:37 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
91 lines
3.9 KiB
Diff
91 lines
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/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
index 5f75c6d653a31f65fcf9c0e280d796e15d059c00..fed29e5707e2a7f64159d284c52647dd91e1948e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
@@ -71,6 +71,26 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick
|
|
return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffectInstance(this.secondaryPower, getLevelCb(), 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 BeaconBlockEntity() {
|
|
super(BlockEntityType.BEACON);
|
|
@@ -261,7 +281,8 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick
|
|
|
|
public List getHumansInRange() {
|
|
{
|
|
- double d0 = (double) (this.levels * 10 + 10);
|
|
+ // Paper - custom beacon ranges
|
|
+ double d0 = this.getEffectRange();
|
|
|
|
AABB axisalignedbb = (new AABB(this.worldPosition)).inflate(d0).expandTowards(0.0D, (double) this.level.getMaxBuildHeight(), 0.0D);
|
|
List<net.minecraft.world.entity.player.Player> list = this.level.getEntitiesOfClass(net.minecraft.world.entity.player.Player.class, axisalignedbb);
|
|
@@ -361,6 +382,9 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick
|
|
this.secondaryPower = MobEffect.byId(tag.getInt("Secondary"));
|
|
this.levels = tag.getInt("Levels"); // SPIGOT-5053, use where available
|
|
// CraftBukkit end
|
|
+ // Paper
|
|
+ this.effectRange = tag.contains(PAPER_RANGE_TAG, 6) ? tag.getDouble(PAPER_RANGE_TAG) : -1;
|
|
+
|
|
if (tag.contains("CustomName", 8)) {
|
|
this.name = Component.Serializer.fromJson(tag.getString("CustomName"));
|
|
}
|
|
@@ -377,6 +401,8 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick
|
|
if (this.name != null) {
|
|
tag.putString("CustomName", Component.Serializer.toJson(this.name));
|
|
}
|
|
+ // Paper
|
|
+ tag.putDouble(PAPER_RANGE_TAG, this.effectRange);
|
|
|
|
this.lockKey.addToTag(tag);
|
|
return tag;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
|
index 940fef58f14e06213c7f305f67dcb8918976c03d..2a10a9352fdb52f5cb27eae2b6d3baa9ff95e486 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<BeaconBlockEntity> implem
|
|
public void setLock(String key) {
|
|
this.getSnapshot().lockKey = (key == null) ? LockCode.NO_LOCK : new LockCode(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();
|
|
+ }
|
|
}
|