diff --git a/patches/server/Add-option-to-disable-block-updates.patch b/patches/server/Add-option-to-disable-block-updates.patch new file mode 100644 index 0000000000..0becb40a95 --- /dev/null +++ b/patches/server/Add-option-to-disable-block-updates.patch @@ -0,0 +1,107 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Boy +Date: Sun, 18 Jun 2023 17:45:33 +0200 +Subject: [PATCH] Add option to disable block updates + + +diff --git a/src/main/java/net/minecraft/world/level/block/NoteBlock.java b/src/main/java/net/minecraft/world/level/block/NoteBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/NoteBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/NoteBlock.java +@@ -0,0 +0,0 @@ public class NoteBlock extends Block { + + @Override + public BlockState getStateForPlacement(BlockPlaceContext ctx) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableNoteblockUpdates) return this.defaultBlockState(); // Paper - place without considering instrument + return this.setInstrument(ctx.getLevel(), ctx.getClickedPos(), this.defaultBlockState()); + } + + @Override + public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableNoteblockUpdates) return state; // Paper - prevent noteblock instrument from updating + boolean flag = direction.getAxis() == Direction.Axis.Y; + + return flag ? this.setInstrument(world, pos, state) : super.updateShape(state, direction, neighborState, world, pos, neighborPos); +@@ -0,0 +0,0 @@ public class NoteBlock extends Block { + + @Override + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableNoteblockUpdates) return; // Paper - prevent noteblock powered-state from updating + boolean flag1 = world.hasNeighborSignal(pos); + + if (flag1 != (Boolean) state.getValue(NoteBlock.POWERED)) { +@@ -0,0 +0,0 @@ public class NoteBlock extends Block { + } else if (world.isClientSide) { + return InteractionResult.SUCCESS; + } else { +- state = (BlockState) state.cycle(NoteBlock.NOTE); ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableNoteblockUpdates) state = (BlockState) state.cycle(NoteBlock.NOTE); // Paper - prevent noteblock note from updating + world.setBlock(pos, state, 3); + this.playNote(player, state, world, pos); + player.awardStat(Stats.TUNE_NOTEBLOCK); +diff --git a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java +@@ -0,0 +0,0 @@ public class TripWireBlock extends Block { + + @Override + public BlockState getStateForPlacement(BlockPlaceContext ctx) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return this.defaultBlockState(); // Paper - place tripwire without updating + Level world = ctx.getLevel(); + BlockPos blockposition = ctx.getClickedPos(); + +@@ -0,0 +0,0 @@ public class TripWireBlock extends Block { + + @Override + public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return state; // Paper - prevent tripwire from updating + return direction.getAxis().isHorizontal() ? (BlockState) state.setValue((Property) TripWireBlock.PROPERTY_BY_DIRECTION.get(direction), this.shouldConnectTo(neighborState, direction)) : super.updateShape(state, direction, neighborState, world, pos, neighborPos); + } + + @Override + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent adjacent tripwires from updating + if (!oldState.is(state.getBlock())) { + this.updateSource(world, pos, state); + } +@@ -0,0 +0,0 @@ public class TripWireBlock extends Block { + + @Override + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent adjacent tripwires from updating + if (!moved && !state.is(newState.getBlock())) { + this.updateSource(world, pos, (BlockState) state.setValue(TripWireBlock.POWERED, true), true); // Paper - fix state inconsistency + } +@@ -0,0 +0,0 @@ public class TripWireBlock extends Block { + + @Override + public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent disarming tripwires + if (!world.isClientSide && !player.getMainHandItem().isEmpty() && player.getMainHandItem().is(Items.SHEARS)) { + world.setBlock(pos, (BlockState) state.setValue(TripWireBlock.DISARMED, true), 4); + world.gameEvent((Entity) player, GameEvent.SHEAR, pos); +@@ -0,0 +0,0 @@ public class TripWireBlock extends Block { + } + + private void updateSource(Level world, BlockPos pos, BlockState state) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent adjacent tripwires from updating + // Paper start - fix state inconsistency + this.updateSource(world, pos, state, false); + } +@@ -0,0 +0,0 @@ public class TripWireBlock extends Block { + + @Override + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent tripwires from detecting collision + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (!world.isClientSide) { + if (!(Boolean) state.getValue(TripWireBlock.POWERED)) { +@@ -0,0 +0,0 @@ public class TripWireBlock extends Block { + + @Override + public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent tripwire pressed check + if ((Boolean) world.getBlockState(pos).getValue(TripWireBlock.POWERED)) { + this.checkPressed(world, pos); + } diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 726be4e525..84b6e5c31d 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -719,6 +719,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean useDimensionTypeForCustomSpawners = false; + public boolean strictAdvancementDimensionCheck = false; + } ++ ++ public BlockUpdates blockUpdates; ++ ++ public class BlockUpdates extends ConfigurationPart { ++ public boolean disableNoteblockUpdates = false; ++ public boolean disableTripwireUpdates = false; ++ } +} diff --git a/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java b/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java new file mode 100644 diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index 0779ba6ebd..11291ed053 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -15699,8 +15699,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public class UnsupportedSettings extends ConfigurationPart { @@ -0,0 +0,0 @@ public class GlobalConfiguration extends ConfigurationPart { - public boolean useDimensionTypeForCustomSpawners = false; - public boolean strictAdvancementDimensionCheck = false; + public boolean disableNoteblockUpdates = false; + public boolean disableTripwireUpdates = false; } + + public ChunkLoadingBasic chunkLoadingBasic;