mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
90 lines
3.9 KiB
Diff
90 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
|
@@ -0,0 +0,0 @@ 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);
|
|
@@ -0,0 +0,0 @@ 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);
|
|
@@ -0,0 +0,0 @@ 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"));
|
|
}
|
|
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
|
@@ -0,0 +0,0 @@ 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();
|
|
+ }
|
|
}
|