aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2022-02-20 13:44:14 -0800
committerGitHub <[email protected]>2022-02-20 13:44:14 -0800
commit392acfdaa4153a269b6bc53e23efb4fd0b809588 (patch)
treefe5eb5dac512a20eba0e3f8a0a6528f3e7786e9a
parent36a1650dbfb1f43e38b6f61fc05e65dc82de0736 (diff)
downloadPaper-392acfdaa4153a269b6bc53e23efb4fd0b809588.tar.gz
Paper-392acfdaa4153a269b6bc53e23efb4fd0b809588.zip
Configurable sculk sensor listener range (#6443)
-rw-r--r--build-data/paper.at3
-rw-r--r--patches/api/0369-Configurable-sculk-sensor-listener-range.patch30
-rw-r--r--patches/server/0872-Configurable-sculk-sensor-listener-range.patch47
3 files changed, 80 insertions, 0 deletions
diff --git a/build-data/paper.at b/build-data/paper.at
index eff98f86f1..6f731e0677 100644
--- a/build-data/paper.at
+++ b/build-data/paper.at
@@ -308,3 +308,6 @@ public org.bukkit.craftbukkit.block.data.CraftBlockData toNMS(Ljava/lang/Enum;Lj
# Stronghold seed configuration
public-f net.minecraft.world.level.chunk.ChunkGenerator strongholdSeed
+
+# More Sculk Sensor API
+public-f net.minecraft.world.level.gameevent.vibrations.VibrationListener listenerRange
diff --git a/patches/api/0369-Configurable-sculk-sensor-listener-range.patch b/patches/api/0369-Configurable-sculk-sensor-listener-range.patch
new file mode 100644
index 0000000000..b1ad0cdb5b
--- /dev/null
+++ b/patches/api/0369-Configurable-sculk-sensor-listener-range.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Thu, 19 Aug 2021 18:43:16 -0700
+Subject: [PATCH] Configurable sculk sensor listener range
+
+
+diff --git a/src/main/java/org/bukkit/block/SculkSensor.java b/src/main/java/org/bukkit/block/SculkSensor.java
+index 18966117823eda97e37627fe72b3dbc2c67cab7c..95a822613093479821c22c9aeea32b27d3ec2e21 100644
+--- a/src/main/java/org/bukkit/block/SculkSensor.java
++++ b/src/main/java/org/bukkit/block/SculkSensor.java
+@@ -24,4 +24,19 @@ public interface SculkSensor extends TileState {
+ * @param lastVibrationFrequency frequency between 0-15.
+ */
+ void setLastVibrationFrequency(int lastVibrationFrequency);
++ // Paper start
++ /**
++ * Gets the range this sensor listens to events at.
++ *
++ * @return the range (defaults to 8)
++ */
++ int getListenerRange();
++
++ /**
++ * Sets the range this sensor will listen to events from.
++ *
++ * @param range the range (must be greater than 0)
++ */
++ void setListenerRange(int range);
++ // Paper end
+ }
diff --git a/patches/server/0872-Configurable-sculk-sensor-listener-range.patch b/patches/server/0872-Configurable-sculk-sensor-listener-range.patch
new file mode 100644
index 0000000000..2e9adfa399
--- /dev/null
+++ b/patches/server/0872-Configurable-sculk-sensor-listener-range.patch
@@ -0,0 +1,47 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Thu, 19 Aug 2021 18:45:42 -0700
+Subject: [PATCH] Configurable sculk sensor listener range
+
+
+diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
+index 2b1e61dacaf4338d7584dea197c7439251951d81..16506b950bbe12f28cf0217b6131128723019e54 100644
+--- a/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
++++ b/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
+@@ -26,12 +26,15 @@ public class SculkSensorBlockEntity extends BlockEntity implements VibrationList
+ public void load(CompoundTag nbt) {
+ super.load(nbt);
+ this.lastVibrationFrequency = nbt.getInt("last_vibration_frequency");
++ if (nbt.contains(PAPER_LISTENER_RANGE_NBT_KEY)) this.listener.listenerRange = nbt.getInt(PAPER_LISTENER_RANGE_NBT_KEY); // Paper
+ }
+
++ private static final String PAPER_LISTENER_RANGE_NBT_KEY = "Paper.ListenerRange"; // Paper
+ @Override
+ protected void saveAdditional(CompoundTag nbt) {
+ super.saveAdditional(nbt);
+ nbt.putInt("last_vibration_frequency", this.lastVibrationFrequency);
++ if (this.listener.listenerRange != ((SculkSensorBlock) net.minecraft.world.level.block.Blocks.SCULK_SENSOR).getListenerRange()) nbt.putInt(PAPER_LISTENER_RANGE_NBT_KEY, this.listener.listenerRange); // Paper - only save if it's different from the default
+ }
+
+ public VibrationListener getListener() {
+diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
+index 2733154f569002e426690dfcf362ff20da8cba72..34362768f38fb3122abcbd5e63fee38a631b9ee3 100644
+--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
+@@ -21,4 +21,16 @@ public class CraftSculkSensor extends CraftBlockEntityState<SculkSensorBlockEnti
+ Preconditions.checkArgument(0 <= lastVibrationFrequency && lastVibrationFrequency <= 15, "Vibration frequency must be between 0-15");
+ getSnapshot().lastVibrationFrequency = lastVibrationFrequency;
+ }
++ // Paper start
++ @Override
++ public int getListenerRange() {
++ return this.getSnapshot().getListener().listenerRange;
++ }
++
++ @Override
++ public void setListenerRange(int range) {
++ Preconditions.checkArgument(range > 0, "Vibration listener range must be greater than 0");
++ this.getSnapshot().getListener().listenerRange = range;
++ }
++ // Paper end
+ }