Search in sources :

Example 1 with ConfigInfo

use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.

the class GuiGauge method renderToolTip.

@Override
public void renderToolTip(@Nonnull MatrixStack matrix, int mouseX, int mouseY) {
    super.renderToolTip(matrix, mouseX, mouseY);
    ItemStack stack = minecraft.player.inventory.getCarried();
    EnumColor color = getGaugeColor().getColor();
    if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurator && color != null) {
        if (gui() instanceof GuiMekanismTile) {
            TileEntityMekanism tile = ((GuiMekanismTile<?, ?>) gui()).getTileEntity();
            if (tile instanceof ISideConfiguration && getTransmission() != null) {
                DataType dataType = null;
                ConfigInfo config = ((ISideConfiguration) tile).getConfig().getConfig(getTransmission());
                if (config != null) {
                    Set<DataType> supportedDataTypes = config.getSupportedDataTypes();
                    for (DataType type : supportedDataTypes) {
                        if (type.getColor() == color) {
                            dataType = type;
                            break;
                        }
                    }
                }
                if (dataType == null) {
                    displayTooltip(matrix, MekanismLang.GENERIC_PARENTHESIS.translateColored(color, color.getName()), mouseX, mouseY);
                } else {
                    displayTooltip(matrix, MekanismLang.GENERIC_WITH_PARENTHESIS.translateColored(color, dataType, color.getName()), mouseX, mouseY);
                }
            }
        }
    } else {
        List<ITextComponent> list = new ArrayList<>();
        if (getLabel() != null) {
            list.add(getLabel());
        }
        list.addAll(getTooltipText());
        displayTooltips(matrix, list, mouseX, mouseY);
    }
}
Also used : TileEntityMekanism(mekanism.common.tile.base.TileEntityMekanism) EnumColor(mekanism.api.text.EnumColor) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) ItemConfigurator(mekanism.common.item.ItemConfigurator) DataType(mekanism.common.tile.component.config.DataType) ItemStack(net.minecraft.item.ItemStack) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile) ISideConfiguration(mekanism.common.tile.interfaces.ISideConfiguration)

Example 2 with ConfigInfo

use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.

the class BlockEnergyCube method getShape.

@Nonnull
@Override
@Deprecated
public VoxelShape getShape(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull ISelectionContext context) {
    TileEntityEnergyCube energyCube = WorldUtils.getTileEntity(TileEntityEnergyCube.class, world, pos, true);
    int index;
    if (energyCube == null) {
        // Default to facing north all enabled
        index = getIndex(1, 1, 1, 1, 1, 1, false, false);
    } else {
        ConfigInfo energyConfig = energyCube.configComponent.getConfig(TransmissionType.ENERGY);
        if (energyConfig == null) {
            // Default to facing north all enabled
            index = getIndex(1, 1, 1, 1, 1, 1, false, false);
        } else {
            Direction facing = Attribute.get(this, AttributeStateFacing.class).getDirection(state);
            index = getIndex(// top
            isSideEnabled(energyConfig, facing, Direction.UP), // bottom
            isSideEnabled(energyConfig, facing, Direction.DOWN), // front
            isSideEnabled(energyConfig, facing, Direction.SOUTH), // back
            isSideEnabled(energyConfig, facing, Direction.NORTH), // left
            isSideEnabled(energyConfig, facing, Direction.EAST), // right
            isSideEnabled(energyConfig, facing, Direction.WEST), facing == Direction.EAST || facing == Direction.WEST, facing == Direction.DOWN || facing == Direction.UP);
        }
    }
    return bounds[index];
}
Also used : TileEntityEnergyCube(mekanism.common.tile.TileEntityEnergyCube) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) Direction(net.minecraft.util.Direction) AttributeStateFacing(mekanism.common.block.attribute.AttributeStateFacing) Nonnull(javax.annotation.Nonnull)

Example 3 with ConfigInfo

use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.

the class ModelEnergyCube method renderSidesBatched.

public void renderSidesBatched(@Nonnull TileEntityEnergyCube tile, @Nonnull MatrixStack matrix, @Nonnull IRenderTypeBuffer renderer, int light, int overlayLight) {
    Set<RelativeSide> enabledSides = EnumSet.noneOf(RelativeSide.class);
    Set<RelativeSide> outputSides = EnumSet.noneOf(RelativeSide.class);
    ConfigInfo config = tile.getConfig().getConfig(TransmissionType.ENERGY);
    if (config != null) {
        for (RelativeSide side : EnumUtils.SIDES) {
            ISlotInfo slotInfo = config.getSlotInfo(side);
            if (slotInfo != null) {
                if (slotInfo.canInput()) {
                    enabledSides.add(side);
                } else if (slotInfo.canOutput()) {
                    enabledSides.add(side);
                    outputSides.add(side);
                }
            }
        }
    }
    renderSidesBatched(matrix, renderer, light, overlayLight, enabledSides, outputSides, false);
}
Also used : ISlotInfo(mekanism.common.tile.component.config.slot.ISlotInfo) RelativeSide(mekanism.api.RelativeSide) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo)

Example 4 with ConfigInfo

use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.

the class ISideConfiguration method getActiveDataType.

@Nullable
default DataType getActiveDataType(Object container) {
    ConfigInfo info = null;
    TileComponentConfig config = getConfig();
    if (container instanceof IGasTank && config.supports(TransmissionType.GAS)) {
        info = config.getConfig(TransmissionType.GAS);
    } else if (container instanceof IInfusionTank && config.supports(TransmissionType.INFUSION)) {
        info = config.getConfig(TransmissionType.INFUSION);
    } else if (container instanceof IPigmentTank && config.supports(TransmissionType.PIGMENT)) {
        info = config.getConfig(TransmissionType.PIGMENT);
    } else if (container instanceof ISlurryTank && config.supports(TransmissionType.SLURRY)) {
        info = config.getConfig(TransmissionType.SLURRY);
    } else if (container instanceof IExtendedFluidTank && config.supports(TransmissionType.FLUID)) {
        info = config.getConfig(TransmissionType.FLUID);
    } else if (container instanceof IInventorySlot && config.supports(TransmissionType.ITEM)) {
        info = config.getConfig(TransmissionType.ITEM);
    }
    if (info != null) {
        List<DataType> types = info.getDataTypeForContainer(container);
        int count = types.size();
        // of <= size - 1 to cut down slightly on the calculations
        if (count > 0 && count < info.getSupportedDataTypes().size()) {
            return types.get(0);
        }
    }
    return null;
}
Also used : IInventorySlot(mekanism.api.inventory.IInventorySlot) IPigmentTank(mekanism.api.chemical.pigment.IPigmentTank) IInfusionTank(mekanism.api.chemical.infuse.IInfusionTank) IGasTank(mekanism.api.chemical.gas.IGasTank) DataType(mekanism.common.tile.component.config.DataType) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) TileComponentConfig(mekanism.common.tile.component.TileComponentConfig) IExtendedFluidTank(mekanism.api.fluid.IExtendedFluidTank) ISlurryTank(mekanism.api.chemical.slurry.ISlurryTank) Nullable(javax.annotation.Nullable)

Example 5 with ConfigInfo

use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.

the class TileComponentConfig method setupOutputConfig.

public ConfigInfo setupOutputConfig(TransmissionType type, Object container, RelativeSide... sides) {
    ConfigInfo config = getConfig(type);
    if (config != null) {
        config.addSlotInfo(DataType.OUTPUT, createInfo(type, false, true, container));
        config.setDataType(DataType.OUTPUT, sides);
        config.setEjecting(true);
    }
    return config;
}
Also used : ConfigInfo(mekanism.common.tile.component.config.ConfigInfo)

Aggregations

ConfigInfo (mekanism.common.tile.component.config.ConfigInfo)27 TransmissionType (mekanism.common.lib.transmitter.TransmissionType)10 DataType (mekanism.common.tile.component.config.DataType)9 RelativeSide (mekanism.api.RelativeSide)8 Direction (net.minecraft.util.Direction)6 ArrayList (java.util.ArrayList)5 ComputerMethod (mekanism.common.integration.computer.annotation.ComputerMethod)5 CompoundNBT (net.minecraft.nbt.CompoundNBT)5 IInventorySlot (mekanism.api.inventory.IInventorySlot)4 ISlotInfo (mekanism.common.tile.component.config.slot.ISlotInfo)4 InventorySlotInfo (mekanism.common.tile.component.config.slot.InventorySlotInfo)4 TileEntity (net.minecraft.tileentity.TileEntity)4 EnumMap (java.util.EnumMap)3 Map (java.util.Map)3 Nonnull (javax.annotation.Nonnull)3 Nullable (javax.annotation.Nullable)3 ComputerException (mekanism.common.integration.computer.ComputerException)3 TileEntityMekanism (mekanism.common.tile.base.TileEntityMekanism)3 ISideConfiguration (mekanism.common.tile.interfaces.ISideConfiguration)3 HashMap (java.util.HashMap)2