From 552c78a7a0781a411c9c13bde271fc10c36ba56f Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 13 Sep 2021 18:55:45 -0700 Subject: [PATCH] prevent unintended light block manipulation --- .../world/level/block/LightBlock.java.patch | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/LightBlock.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LightBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LightBlock.java.patch new file mode 100644 index 0000000000..4e34991e01 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LightBlock.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/level/block/LightBlock.java ++++ b/net/minecraft/world/level/block/LightBlock.java +@@ -50,7 +50,15 @@ + builder.add(LEVEL, WATERLOGGED); + } + ++ // Paper start - prevent unintended light block manipulation + @Override ++ protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, net.minecraft.world.InteractionHand hand, BlockHitResult hit) { ++ if (player.getItemInHand(hand).getItem() != Items.LIGHT || (world instanceof final net.minecraft.server.level.ServerLevel serverLevel && !player.mayInteract(serverLevel, pos)) || !player.mayUseItemAt(pos, hit.getDirection(), player.getItemInHand(hand))) { return net.minecraft.world.InteractionResult.PASS; } // Paper - Prevent unintended light block manipulation ++ return super.useItemOn(stack, state, world, pos, player, hand, hit); ++ } ++ // Paper end - prevent unintended light block manipulation ++ ++ @Override + protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { + if (!world.isClientSide && player.canUseGameMasterBlocks()) { + world.setBlock(pos, state.cycle(LEVEL), 2);