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/ChorusPlantBlock.java b/src/main/java/net/minecraft/world/level/block/ChorusPlantBlock.java index ad801476cc25d51e4145a41b9c8100382f1f49bb..1ba7a6a14f7fbfdd279cb8c2bebf5ea6c98dbf1f 100644 --- a/src/main/java/net/minecraft/world/level/block/ChorusPlantBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ChorusPlantBlock.java @@ -38,6 +38,7 @@ public class ChorusPlantBlock extends PipeBlock { @Override public BlockState getStateForPlacement(BlockPlaceContext ctx) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return this.defaultBlockState(); // Paper - add option to disable block updates return getStateWithConnections(ctx.getLevel(), ctx.getClickedPos(), this.defaultBlockState()); } @@ -59,6 +60,7 @@ public class ChorusPlantBlock extends PipeBlock { @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return state; // Paper - add option to disable block updates if (!state.canSurvive(world, pos)) { world.scheduleTick(pos, this, 1); return super.updateShape(state, direction, neighborState, world, pos, neighborPos); @@ -70,6 +72,7 @@ public class ChorusPlantBlock extends PipeBlock { @Override public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return; // Paper - add option to disable block updates if (!state.canSurvive(world, pos)) { world.destroyBlock(pos, true); } @@ -77,6 +80,7 @@ public class ChorusPlantBlock extends PipeBlock { @Override public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return true; // Paper - add option to disable block updates BlockState blockState = world.getBlockState(pos.below()); boolean bl = !world.getBlockState(pos.above()).isAir() && !blockState.isAir(); diff --git a/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java b/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java index 322cd656b82611ca8048c3e35cb66551bdea87d6..f70898bddec0b53f92ab88b862e2d865d82d558d 100644 --- a/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java +++ b/src/main/java/net/minecraft/world/level/block/HugeMushroomBlock.java @@ -43,6 +43,7 @@ public class HugeMushroomBlock extends Block { @Override public BlockState getStateForPlacement(BlockPlaceContext ctx) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableMushroomBlockUpdates) return this.defaultBlockState(); // Paper - add option to disable block updates BlockGetter blockGetter = ctx.getLevel(); BlockPos blockPos = ctx.getClickedPos(); return this.defaultBlockState() @@ -56,6 +57,7 @@ public class HugeMushroomBlock 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.disableMushroomBlockUpdates) return state; // Paper - add option to disable block updates return neighborState.is(this) ? state.setValue(PROPERTY_BY_DIRECTION.get(direction), Boolean.valueOf(false)) : super.updateShape(state, direction, neighborState, world, pos, neighborPos); @@ -63,6 +65,7 @@ public class HugeMushroomBlock extends Block { @Override public BlockState rotate(BlockState state, Rotation rotation) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableMushroomBlockUpdates) return state; // Paper - add option to disable block updates return state.setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.NORTH)), state.getValue(NORTH)) .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.SOUTH)), state.getValue(SOUTH)) .setValue(PROPERTY_BY_DIRECTION.get(rotation.rotate(Direction.EAST)), state.getValue(EAST)) @@ -73,6 +76,7 @@ public class HugeMushroomBlock extends Block { @Override public BlockState mirror(BlockState state, Mirror mirror) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableMushroomBlockUpdates) return state; // Paper - add option to disable block updates return state.setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.NORTH)), state.getValue(NORTH)) .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.SOUTH)), state.getValue(SOUTH)) .setValue(PROPERTY_BY_DIRECTION.get(mirror.mirror(Direction.EAST)), state.getValue(EAST)) 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 92a24cf02f15f3ab893eb9a793770d9819e4f600..a541dc3a6e373b30fff0abf5305e77854c190f10 100644 --- a/src/main/java/net/minecraft/world/level/block/NoteBlock.java +++ b/src/main/java/net/minecraft/world/level/block/NoteBlock.java @@ -65,11 +65,13 @@ 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); @@ -77,6 +79,7 @@ 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)) { @@ -114,7 +117,7 @@ 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 003fd247b12323cca5fd82a6cdf31bd897afd682..bdb99b799d1a97f1340c3d388d2901f7cb1c3527 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java @@ -66,6 +66,7 @@ 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(); @@ -74,11 +75,13 @@ 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); } @@ -86,6 +89,7 @@ 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)); } @@ -93,6 +97,7 @@ public class TripWireBlock extends Block { @Override public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return state; // 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); @@ -102,6 +107,7 @@ 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 Direction[] aenumdirection = new Direction[]{Direction.SOUTH, Direction.WEST}; int i = aenumdirection.length; int j = 0; @@ -134,6 +140,7 @@ 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 - Add EntityInsideBlockEvent if (!world.isClientSide) { if (!(Boolean) state.getValue(TripWireBlock.POWERED)) { @@ -144,6 +151,7 @@ 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); }