mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-12 06:58:11 +02:00
* Update patches to handle vineflower decompiler * update patches again to handle inlined simple lambdas * update vf again and re-apply/rebuild patches * update patches after removal of verify-merges flag * fix compile issue * remove maven local * fix some issues * address more issues * fix collision patch * use paperweight release * more fixes * update fineflower and fix patches again * add missing comment descriptor --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
107 lines
5.8 KiB
Diff
107 lines
5.8 KiB
Diff
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
|
|
|
|
== AT ==
|
|
public-f net.minecraft.world.level.gameevent.vibrations.VibrationListener listenerRange
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java
|
|
index 4c9c35131e9bd37a48f6c4beb2bbcaf7988069c5..cf865dcfde2ae6c0ae72a8e7469be2dd3e1bc679 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java
|
|
@@ -19,6 +19,12 @@ public class CalibratedSculkSensorBlockEntity extends SculkSensorBlockEntity {
|
|
public VibrationSystem.User createVibrationUser() {
|
|
return new CalibratedSculkSensorBlockEntity.VibrationUser(this.getBlockPos());
|
|
}
|
|
+ // Paper start - Configurable sculk sensor listener range
|
|
+ @Override
|
|
+ protected void saveRangeOverride(final net.minecraft.nbt.CompoundTag nbt) {
|
|
+ if (this.rangeOverride != null && this.rangeOverride != 16) nbt.putInt(PAPER_LISTENER_RANGE_NBT_KEY, this.rangeOverride); // only save if it's different from the default
|
|
+ }
|
|
+ // Paper end - Configurable sculk sensor listener range
|
|
|
|
protected class VibrationUser extends SculkSensorBlockEntity.VibrationUser {
|
|
public VibrationUser(BlockPos pos) {
|
|
@@ -27,6 +33,7 @@ public class CalibratedSculkSensorBlockEntity extends SculkSensorBlockEntity {
|
|
|
|
@Override
|
|
public int getListenerRadius() {
|
|
+ if (CalibratedSculkSensorBlockEntity.this.rangeOverride != null) return CalibratedSculkSensorBlockEntity.this.rangeOverride; // Paper - Configurable sculk sensor listener range
|
|
return 16;
|
|
}
|
|
|
|
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 fd791916336032e29aae83a2ff5d956bc18f2938..a08a59192cd01789b4aff9af6d0f1d4c27bb4fe1 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
|
|
@@ -23,6 +23,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
private final VibrationSystem.Listener vibrationListener;
|
|
private final VibrationSystem.User vibrationUser = this.createVibrationUser();
|
|
public int lastVibrationFrequency;
|
|
+ @Nullable public Integer rangeOverride = null; // Paper - Configurable sculk sensor listener range
|
|
|
|
protected SculkSensorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
|
super(type, pos, state);
|
|
@@ -48,8 +49,16 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
.resultOrPartial(LOGGER::error)
|
|
.ifPresent(listener -> this.vibrationData = listener);
|
|
}
|
|
+ // Paper start - Configurable sculk sensor listener range
|
|
+ if (nbt.contains(PAPER_LISTENER_RANGE_NBT_KEY)) {
|
|
+ this.rangeOverride = nbt.getInt(PAPER_LISTENER_RANGE_NBT_KEY);
|
|
+ } else {
|
|
+ this.rangeOverride = null;
|
|
+ }
|
|
+ // Paper end - Configurable sculk sensor listener range
|
|
}
|
|
|
|
+ protected static final String PAPER_LISTENER_RANGE_NBT_KEY = "Paper.ListenerRange"; // Paper - Configurable sculk sensor listener range
|
|
@Override
|
|
protected void saveAdditional(CompoundTag nbt) {
|
|
super.saveAdditional(nbt);
|
|
@@ -58,7 +67,13 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
.encodeStart(NbtOps.INSTANCE, this.vibrationData)
|
|
.resultOrPartial(LOGGER::error)
|
|
.ifPresent(listenerNbt -> nbt.put("listener", listenerNbt));
|
|
+ this.saveRangeOverride(nbt); // Paper - Configurable sculk sensor listener range
|
|
+ }
|
|
+ // Paper start - Configurable sculk sensor listener range
|
|
+ protected void saveRangeOverride(CompoundTag nbt) {
|
|
+ if (this.rangeOverride != null && this.rangeOverride != VibrationUser.LISTENER_RANGE) nbt.putInt(PAPER_LISTENER_RANGE_NBT_KEY, this.rangeOverride); // only save if it's different from the default
|
|
}
|
|
+ // Paper end - Configurable sculk sensor listener range
|
|
|
|
@Override
|
|
public VibrationSystem.Data getVibrationData() {
|
|
@@ -95,6 +110,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
|
|
@Override
|
|
public int getListenerRadius() {
|
|
+ if (SculkSensorBlockEntity.this.rangeOverride != null) return SculkSensorBlockEntity.this.rangeOverride; // Paper - Configurable sculk sensor listener range
|
|
return 8;
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
|
|
index 0e5e316b6c76c3929cca037eddf52120767862ff..c796a1754385edabe115088ebb5aa2f44cfa657a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java
|
|
@@ -30,4 +30,17 @@ public class CraftSculkSensor<T extends SculkSensorBlockEntity> extends CraftBlo
|
|
public CraftSculkSensor<T> copy() {
|
|
return new CraftSculkSensor<>(this);
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public int getListenerRange() {
|
|
+ return this.getSnapshot().getListener().getListenerRadius();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setListenerRange(int range) {
|
|
+ Preconditions.checkArgument(range > 0, "Vibration listener range must be greater than 0");
|
|
+ this.getSnapshot().rangeOverride = range;
|
|
+ }
|
|
+ // Paper end
|
|
}
|