mirror of
https://github.com/PaperMC/Paper.git
synced 2024-10-30 07:19:58 +01:00
95 lines
4.0 KiB
Diff
95 lines
4.0 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 0fa01b98f4a2ce2a7d34437a71d8c1cc7e718fb1..1df7a4a937729fc402f80021434ddf3481facd94 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
|
||
|
@@ -79,6 +79,26 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||
|
return (BeaconBlockEntity.hasSecondaryEffect(this.levels, this.primaryPower, this.secondaryPower)) ? CraftPotionUtil.toBukkit(new MobEffectInstance(this.secondaryPower, BeaconBlockEntity.getLevel(this.levels), BeaconBlockEntity.getAmplification(this.levels, this.primaryPower, this.secondaryPower), 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(BlockPos pos, BlockState state) {
|
||
|
super(BlockEntityType.BEACON, pos, state);
|
||
|
@@ -268,8 +288,13 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||
|
}
|
||
|
|
||
|
public static List getHumansInRange(Level world, BlockPos blockposition, int i) {
|
||
|
+ // Paper start
|
||
|
+ return BeaconBlockEntity.getHumansInRange(world, blockposition, i, null);
|
||
|
+ }
|
||
|
+ public static List getHumansInRange(Level world, BlockPos blockposition, int i, @Nullable BeaconBlockEntity blockEntity) {
|
||
|
+ // Paper end
|
||
|
{
|
||
|
- double d0 = (double) (i * 10 + 10);
|
||
|
+ double d0 = blockEntity != null ? blockEntity.getEffectRange() : (i * 10 + 10);// Paper - custom beacon ranges
|
||
|
|
||
|
AABB axisalignedbb = (new AABB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D);
|
||
|
List<Player> list = world.getEntitiesOfClass(Player.class, axisalignedbb);
|
||
|
@@ -366,6 +391,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||
|
}
|
||
|
|
||
|
this.lockKey = LockCode.fromTag(nbt);
|
||
|
+ this.effectRange = nbt.contains(PAPER_RANGE_TAG, 6) ? nbt.getDouble(PAPER_RANGE_TAG) : -1; // Paper
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@@ -379,6 +405,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||
|
}
|
||
|
|
||
|
this.lockKey.addToTag(nbt);
|
||
|
+ nbt.putDouble(PAPER_RANGE_TAG, this.effectRange); // Paper
|
||
|
return nbt;
|
||
|
}
|
||
|
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
||
|
index 5abf219e86c6b4cf0c6b2e8ea72d7ed7b4f612e3..e2b2625565a4ac39899de01a7fe660188f04c109 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
||
|
@@ -108,4 +108,21 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||
|
public void setLock(String key) {
|
||
|
this.getSnapshot().lockKey = (key == null) ? LockCode.NO_LOCK : new LockCode(key);
|
||
|
}
|
||
|
+
|
||
|
+ // Paper start
|
||
|
+ @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();
|
||
|
+ }
|
||
|
+ // Paper end
|
||
|
}
|