Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop adventure mode from changing block configs #7043

Open
wants to merge 2 commits into
base: mc1.20.1/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -92,7 +93,6 @@ public static void onBlockActivated(PlayerInteractEvent.RightClickBlock event) {
}

public static boolean canInteract(Player player) {
return player != null && !player.isSpectator() && !player.isShiftKeyDown();
return player != null && !player.isSpectator() && !player.isShiftKeyDown() && !AdventureUtil.isAdventure(player);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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;
Expand Down Expand Up @@ -33,7 +35,7 @@ public void write(FriendlyByteBuf buffer) {
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))
Expand Down Expand Up @@ -63,7 +65,7 @@ protected int maxRange() {
protected void applySettings(ServerPlayer player, BE be) {
applySettings(be);
}

protected boolean causeUpdate() {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}