mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
* feat: enhance update suppression * fix: fix nest exception, better print * fix: bot update suppression catch * chore: format * feat: better performance * fix: fix build err * refactor * fix: throw IAE when call not from net.minecraft * format: use jbr annotation * fix: fix comment pos * chore: format * fix: fix comment * feat: add stacktrace to event
58 lines
3.8 KiB
Diff
58 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MC_XiaoHei <xiaohei.xor7@outlook.com>
|
|
Date: Tue, 20 May 2025 12:08:40 +0000
|
|
Subject: [PATCH] Sound update suppression
|
|
|
|
|
|
diff --git a/net/minecraft/world/level/block/SculkSensorBlock.java b/net/minecraft/world/level/block/SculkSensorBlock.java
|
|
index fa9cb4c40a41eea7fd63a4513d0b0f39067de9ba..a8375b6544a004c96e2b3c7c088831def855febe 100644
|
|
--- a/net/minecraft/world/level/block/SculkSensorBlock.java
|
|
+++ b/net/minecraft/world/level/block/SculkSensorBlock.java
|
|
@@ -97,7 +97,7 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg
|
|
@Override
|
|
public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) {
|
|
if (!level.isClientSide()
|
|
- && canActivate(state)
|
|
+ && canActivate(state, pos) // Leaves - Sound update suppression
|
|
&& entity.getType() != EntityType.WARDEN
|
|
&& level.getBlockEntity(pos) instanceof SculkSensorBlockEntity sculkSensorBlockEntity
|
|
&& level instanceof ServerLevel serverLevel
|
|
@@ -214,6 +214,15 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg
|
|
return state.getValue(PHASE);
|
|
}
|
|
|
|
+ // Leaves start - Sound update suppression
|
|
+ public static boolean canActivate(BlockState state, BlockPos pos) {
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.updater.soundUpdateSuppression && !(state.getBlock() instanceof SculkSensorBlock)) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, null, state.getBlock(), null, new IllegalArgumentException());
|
|
+ }
|
|
+ return canActivate(state);
|
|
+ }
|
|
+ // Leaves end - Sound update suppression
|
|
+
|
|
public static boolean canActivate(BlockState state) {
|
|
return state.getBlock() instanceof SculkSensorBlock && getPhase(state) == SculkSensorPhase.INACTIVE; // Paper - Check for a valid type
|
|
}
|
|
diff --git a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
|
|
index 9a345fa3438b2d17a5de2fa0c0b0daef5a5183e1..f3f92666265e1b6dcb17124b5f52e84a6d62ccf2 100644
|
|
--- a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
|
|
@@ -113,7 +113,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
public boolean canReceiveVibration(ServerLevel level, BlockPos pos, Holder<GameEvent> gameEvent, @Nullable GameEvent.Context context) {
|
|
return (!pos.equals(this.blockPos) || !gameEvent.is(GameEvent.BLOCK_DESTROY) && !gameEvent.is(GameEvent.BLOCK_PLACE))
|
|
&& VibrationSystem.getGameEventFrequency(gameEvent) != 0
|
|
- && SculkSensorBlock.canActivate(SculkSensorBlockEntity.this.getBlockState());
|
|
+ && SculkSensorBlock.canActivate(SculkSensorBlockEntity.this.getBlockState(), pos); // Leaves - Sound update suppression
|
|
}
|
|
|
|
@Override
|
|
@@ -121,7 +121,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
|
|
ServerLevel level, BlockPos pos, Holder<GameEvent> gameEvent, @Nullable Entity entity, @Nullable Entity playerEntity, float distance
|
|
) {
|
|
BlockState blockState = SculkSensorBlockEntity.this.getBlockState();
|
|
- if (SculkSensorBlock.canActivate(blockState)) {
|
|
+ if (SculkSensorBlock.canActivate(blockState, pos)) { // Leaves - Sound update suppression
|
|
int gameEventFrequency = VibrationSystem.getGameEventFrequency(gameEvent);
|
|
SculkSensorBlockEntity.this.setLastVibrationFrequency(gameEventFrequency);
|
|
int redstoneStrengthForDistance = VibrationSystem.getRedstoneStrengthForDistance(distance, this.getListenerRadius());
|