From a1fcb893e1f8912e5a1c6f56111e521eb2737ea7 Mon Sep 17 00:00:00 2001 From: agnor99 <36055315+justliliandev@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:59:19 +0200 Subject: [PATCH] stop adventure mode from changing block configs --- .../blockEntity/behaviour/ValueSettingsInputHandler.java | 2 +- .../networking/BlockEntityConfigurationPacket.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueSettingsInputHandler.java b/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueSettingsInputHandler.java index 5ab4fd684..0194347ce 100644 --- a/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueSettingsInputHandler.java +++ b/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueSettingsInputHandler.java @@ -92,7 +92,7 @@ public class ValueSettingsInputHandler { } public static boolean canInteract(Player player) { - return player != null && !player.isSpectator() && !player.isShiftKeyDown(); + return player != null && player.getAbilities().mayBuild && !player.isShiftKeyDown(); } } diff --git a/src/main/java/com/simibubi/create/foundation/networking/BlockEntityConfigurationPacket.java b/src/main/java/com/simibubi/create/foundation/networking/BlockEntityConfigurationPacket.java index 35d80758f..edd0083db 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/BlockEntityConfigurationPacket.java +++ b/src/main/java/com/simibubi/create/foundation/networking/BlockEntityConfigurationPacket.java @@ -5,6 +5,8 @@ import com.simibubi.create.foundation.blockEntity.SyncedBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.network.NetworkEvent.Context; @@ -33,7 +35,7 @@ public abstract class BlockEntityConfigurationPacket { ServerPlayer player = context.getSender(); - if (player == null) + if (player == null || !player.getAbilities().mayBuild) return; Level world = player.level(); if (world == null || !world.isLoaded(pos)) @@ -63,7 +65,7 @@ public abstract class BlockEntityConfigurationPacket