Work on compile errors

This commit is contained in:
Bjarne Koll 2024-10-25 12:30:19 +02:00
parent afbb0d88dd
commit b06e0b0317
No known key found for this signature in database
GPG key ID: 27F6CCCF55D2EE62
111 changed files with 207 additions and 186 deletions

View file

@ -5,17 +5,27 @@ 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
index 6c3ca57a29d3c5ad1add1cf2f707b930dfc422ea..71a1a152dca41ba9100bd38efd6758a42bab9f5d 100644
index 6c3ca57a29d3c5ad1add1cf2f707b930dfc422ea..606c9b03cc69031faed33f437ca254f12224bb62 100644
--- a/src/main/java/net/minecraft/world/level/block/LightBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LightBlock.java
@@ -50,6 +50,14 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock {
@@ -5,7 +5,9 @@ import java.util.function.ToIntFunction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.component.DataComponents;
+import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
+import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
@@ -50,6 +52,14 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock {
builder.add(LEVEL, WATERLOGGED);
}
+ // Paper start - prevent unintended light block manipulation
+ @Override
+ protected net.minecraft.world.ItemInteractionResult useItemOn(final ItemStack stack, final BlockState state, final Level world, final BlockPos pos, final Player player, final net.minecraft.world.InteractionHand hand, final BlockHitResult hit) {
+ if (player.getItemInHand(hand).getItem() != Items.LIGHT || !player.mayInteract(world, pos) || !player.mayUseItemAt(pos, hit.getDirection(), player.getItemInHand(hand))) { return net.minecraft.world.ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION; } // Paper - Prevent unintended light block manipulation
+ protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
+ if (player.getItemInHand(hand).getItem() != Items.LIGHT || (world instanceof final 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