stop adventure mode from changing block configs (#7043)

This commit is contained in:
justliliandev 2025-02-14 10:02:53 +01:00 committed by GitHub
parent 2cf08a1231
commit 3f464bcefa
Failed to generate hash of commit
3 changed files with 17 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import com.simibubi.create.AllTags.AllItemTags;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.SidedFilteringBehaviour;
import com.simibubi.create.foundation.utility.AdventureUtil;
import com.simibubi.create.foundation.utility.RaycastHelper;
import net.minecraft.core.BlockPos;
@ -92,7 +93,6 @@ public class ValueSettingsInputHandler {
}
public static boolean canInteract(Player player) {
return player != null && !player.isSpectator() && !player.isShiftKeyDown();
return player != null && !player.isSpectator() && !player.isShiftKeyDown() && !AdventureUtil.isAdventure(player);
}
}

View file

@ -2,6 +2,8 @@ package com.simibubi.create.foundation.networking;
import com.simibubi.create.foundation.blockEntity.SyncedBlockEntity;
import com.simibubi.create.foundation.utility.AdventureUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
@ -33,7 +35,7 @@ public abstract class BlockEntityConfigurationPacket<BE extends SyncedBlockEntit
public boolean handle(Context context) {
context.enqueueWork(() -> {
ServerPlayer player = context.getSender();
if (player == null)
if (player == null || player.isSpectator() || AdventureUtil.isAdventure(player))
return;
Level world = player.level();
if (world == null || !world.isLoaded(pos))
@ -63,7 +65,7 @@ public abstract class BlockEntityConfigurationPacket<BE extends SyncedBlockEntit
protected void applySettings(ServerPlayer player, BE be) {
applySettings(be);
}
protected boolean causeUpdate() {
return true;
}

View file

@ -0,0 +1,11 @@
package com.simibubi.create.foundation.utility;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.Nullable;
public class AdventureUtil {
public static boolean isAdventure(@Nullable Player player) {
return player != null && !player.mayBuild() && !player.isSpectator();
}
}