PaperMC/patches/server/0612-prevent-unintended-light-block-manipulation.patch

26 lines
1.7 KiB
Diff
Raw Permalink Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Mon, 13 Sep 2021 18:55:45 -0700
Subject: [PATCH] prevent unintended light block manipulation
diff --git a/src/main/java/net/minecraft/world/level/block/LightBlock.java b/src/main/java/net/minecraft/world/level/block/LightBlock.java
2024-12-03 19:54:10 +01:00
index 2be8855b2cd50e599d80e1ff5dc13d66451dff9d..9f6bb23b6021a99d4bb09d57659943cfdb4b673f 100644
--- a/src/main/java/net/minecraft/world/level/block/LightBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LightBlock.java
2024-10-25 13:34:01 +02:00
@@ -50,6 +50,14 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock {
2024-04-26 06:27:19 +02:00
builder.add(LEVEL, WATERLOGGED);
}
+ // Paper start - prevent unintended light block manipulation
+ @Override
2024-10-25 13:34:01 +02:00
+ 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
2024-04-26 06:27:19 +02:00
+ return super.useItemOn(stack, state, world, pos, player, hand, hit);
+ }
+ // Paper end - prevent unintended light block manipulation
+
@Override
2024-04-24 17:27:28 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2022-12-07 22:05:01 +01:00
if (!world.isClientSide && player.canUseGameMasterBlocks()) {