Search in sources :

Example 6 with ItemConfigurator

use of mekanism.common.item.ItemConfigurator in project Mekanism by mekanism.

the class TileEntityMekanism method openGui.

public ActionResultType openGui(PlayerEntity player) {
    // Everything that calls this has isRemote being false but add the check just in case anyways
    if (hasGui() && !isRemote() && !player.isShiftKeyDown()) {
        if (hasSecurity() && !SecurityUtils.canAccess(player, this)) {
            SecurityUtils.displayNoAccess(player);
            return ActionResultType.FAIL;
        }
        // Pass on this activation if the player is rotating with a configurator
        ItemStack stack = player.getMainHandItem();
        if (isDirectional() && !stack.isEmpty() && stack.getItem() instanceof ItemConfigurator) {
            ItemConfigurator configurator = (ItemConfigurator) stack.getItem();
            if (configurator.getMode(stack) == ItemConfigurator.ConfiguratorMode.ROTATE) {
                return ActionResultType.PASS;
            }
        }
        // Pass on this activation if the player is using a configuration card (and this tile supports the capability)
        if (getCapability(Capabilities.CONFIG_CARD_CAPABILITY, null).isPresent()) {
            if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurationCard) {
                return ActionResultType.PASS;
            }
        }
        NetworkHooks.openGui((ServerPlayerEntity) player, Attribute.get(getBlockType(), AttributeGui.class).getProvider(this), worldPosition);
        return ActionResultType.SUCCESS;
    }
    return ActionResultType.PASS;
}
Also used : ItemConfigurationCard(mekanism.common.item.ItemConfigurationCard) ItemConfigurator(mekanism.common.item.ItemConfigurator) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemConfigurator (mekanism.common.item.ItemConfigurator)6 ItemStack (net.minecraft.item.ItemStack)6 DataType (mekanism.common.tile.component.config.DataType)3 ISideConfiguration (mekanism.common.tile.interfaces.ISideConfiguration)3 EnumColor (mekanism.api.text.EnumColor)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 Direction (net.minecraft.util.Direction)2 BlockPos (net.minecraft.util.math.BlockPos)2 BlockRayTraceResult (net.minecraft.util.math.BlockRayTraceResult)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 IInventorySlot (mekanism.api.inventory.IInventorySlot)1 GuiMekanismTile (mekanism.client.gui.GuiMekanismTile)1 IWireFrameRenderer (mekanism.client.render.tileentity.IWireFrameRenderer)1 BlockBounding (mekanism.common.block.BlockBounding)1 AttributeCustomSelectionBox (mekanism.common.block.attribute.AttributeCustomSelectionBox)1 DiversionTransporter (mekanism.common.content.network.transmitter.DiversionTransporter)1 LogisticalTransporterBase (mekanism.common.content.network.transmitter.LogisticalTransporterBase)1 TransporterStack (mekanism.common.content.transporter.TransporterStack)1