mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-01 10:51:19 +01:00
Configurable sculk sensor listener range (#6443)
This commit is contained in:
parent
f30c0d1b46
commit
0707073df5
@ -308,3 +308,6 @@ public org.bukkit.craftbukkit.block.data.CraftBlockData toNMS(Ljava/lang/Enum;Lj
|
|||||||
|
|
||||||
# Stronghold seed configuration
|
# Stronghold seed configuration
|
||||||
public-f net.minecraft.world.level.chunk.ChunkGenerator strongholdSeed
|
public-f net.minecraft.world.level.chunk.ChunkGenerator strongholdSeed
|
||||||
|
|
||||||
|
# More Sculk Sensor API
|
||||||
|
public-f net.minecraft.world.level.gameevent.vibrations.VibrationListener listenerRange
|
||||||
|
30
patches/api/Configurable-sculk-sensor-listener-range.patch
Normal file
30
patches/api/Configurable-sculk-sensor-listener-range.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/block/SculkSensor.java
|
||||||
|
+++ b/src/main/java/org/bukkit/block/SculkSensor.java
|
||||||
|
@@ -0,0 +0,0 @@ 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
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
||||||
|
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
|
||||||
|
@@ -0,0 +0,0 @@ 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user