mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-16 00:46:54 +02:00
c0936a71bd
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
107 lines
5.4 KiB
Diff
107 lines
5.4 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 a18589425006ccabd87b76a9827ab516040009bb..fb1c47a17c2fe3807ed54fd2b2bb17c2fe28b901 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
|
|
+ @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
|
|
|
|
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
|
|
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 a6c226da995eecc323d69a3eff1f8d202410e069..5d3740875de337e24fdba28305f61e96d01c457f 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
|
|
@@ -24,6 +24,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
|
|
|
|
protected SculkSensorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
|
super(type, pos, state);
|
|
@@ -48,9 +49,17 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
this.vibrationData = listener;
|
|
});
|
|
}
|
|
+ // Paper start
|
|
+ if (nbt.contains(PAPER_LISTENER_RANGE_NBT_KEY)) {
|
|
+ this.rangeOverride = nbt.getInt(PAPER_LISTENER_RANGE_NBT_KEY);
|
|
+ } else {
|
|
+ this.rangeOverride = null;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
+ protected static final String PAPER_LISTENER_RANGE_NBT_KEY = "Paper.ListenerRange"; // Paper
|
|
@Override
|
|
protected void saveAdditional(CompoundTag nbt) {
|
|
super.saveAdditional(nbt);
|
|
@@ -58,7 +67,13 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
VibrationSystem.Data.CODEC.encodeStart(NbtOps.INSTANCE, this.vibrationData).resultOrPartial(LOGGER::error).ifPresent((listenerNbt) -> {
|
|
nbt.put("listener", listenerNbt);
|
|
});
|
|
+ this.saveRangeOverride(nbt); // Paper
|
|
+ }
|
|
+ // Paper start
|
|
+ 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
|
|
|
|
@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
|
|
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 de804383467518ef0f063aea948514db568f59db..f2599117cc8c12d9402e22c34c76f323b5a1ec5c 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<T extends SculkSensorBlockEntity> extends CraftBlo
|
|
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().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
|
|
}
|