mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-27 13:28:00 +01:00
copy adventureutil class from fabricators-of-create/create
This commit is contained in:
parent
a1fcb893e1
commit
5e7e1d4101
3 changed files with 16 additions and 5 deletions
|
@ -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.getAbilities().mayBuild && !player.isShiftKeyDown();
|
||||
return player != null && !player.isSpectator() && !player.isShiftKeyDown() && !AdventureUtil.isAdventure(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ 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;
|
||||
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;
|
||||
|
@ -35,7 +35,7 @@ public abstract class BlockEntityConfigurationPacket<BE extends SyncedBlockEntit
|
|||
public boolean handle(Context context) {
|
||||
context.enqueueWork(() -> {
|
||||
ServerPlayer player = context.getSender();
|
||||
if (player == null || !player.getAbilities().mayBuild)
|
||||
if (player == null || player.isSpectator() || AdventureUtil.isAdventure(player))
|
||||
return;
|
||||
Level world = player.level();
|
||||
if (world == null || !world.isLoaded(pos))
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue