Search in sources :

Example 6 with ConfigInfo

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

the class TileComponentConfig method read.

@Override
public void read(CompoundNBT nbtTags) {
    if (nbtTags.contains(NBTConstants.COMPONENT_CONFIG, NBT.TAG_COMPOUND)) {
        CompoundNBT configNBT = nbtTags.getCompound(NBTConstants.COMPONENT_CONFIG);
        Set<Direction> directionsToUpdate = EnumSet.noneOf(Direction.class);
        for (Entry<TransmissionType, ConfigInfo> entry : configInfo.entrySet()) {
            TransmissionType type = entry.getKey();
            ConfigInfo info = entry.getValue();
            info.setEjecting(configNBT.getBoolean(NBTConstants.EJECT + type.ordinal()));
            CompoundNBT sideConfig = configNBT.getCompound(NBTConstants.CONFIG + type.ordinal());
            for (RelativeSide side : EnumUtils.SIDES) {
                NBTUtils.setEnumIfPresent(sideConfig, NBTConstants.SIDE + side.ordinal(), DataType::byIndexStatic, dataType -> {
                    if (info.getDataType(side) != dataType) {
                        info.setDataType(dataType, side);
                        if (tile.hasLevel()) {
                            // If we aren't already loaded yet don't do any updates
                            Direction direction = side.getDirection(tile.getDirection());
                            sideChangedBasic(type, direction);
                            directionsToUpdate.add(direction);
                        }
                    }
                });
            }
        }
        WorldUtils.notifyNeighborsOfChange(tile.getLevel(), tile.getBlockPos(), directionsToUpdate);
    }
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) TransmissionType(mekanism.common.lib.transmitter.TransmissionType) RelativeSide(mekanism.api.RelativeSide) DataType(mekanism.common.tile.component.config.DataType) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) Direction(net.minecraft.util.Direction)

Example 7 with ConfigInfo

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

the class TileComponentConfig method setupIOConfig.

public ConfigInfo setupIOConfig(TransmissionType type, Object inputContainer, Object outputContainer, RelativeSide outputSide, boolean alwaysAllowInput, boolean alwaysAllowOutput) {
    ConfigInfo config = getConfig(type);
    if (config != null) {
        config.addSlotInfo(DataType.INPUT, createInfo(type, true, alwaysAllowOutput, inputContainer));
        config.addSlotInfo(DataType.OUTPUT, createInfo(type, alwaysAllowInput, true, outputContainer));
        config.addSlotInfo(DataType.INPUT_OUTPUT, createInfo(type, true, true, Arrays.asList(inputContainer, outputContainer)));
        config.fill(DataType.INPUT);
        config.setDataType(DataType.OUTPUT, outputSide);
    }
    return config;
}
Also used : ConfigInfo(mekanism.common.tile.component.config.ConfigInfo)

Example 8 with ConfigInfo

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

the class TileComponentConfig method setupItemIOConfig.

public ConfigInfo setupItemIOConfig(List<IInventorySlot> inputSlots, List<IInventorySlot> outputSlots, IInventorySlot energySlot, boolean alwaysAllow) {
    ConfigInfo itemConfig = getConfig(TransmissionType.ITEM);
    if (itemConfig != null) {
        itemConfig.addSlotInfo(DataType.INPUT, new InventorySlotInfo(true, alwaysAllow, inputSlots));
        itemConfig.addSlotInfo(DataType.OUTPUT, new InventorySlotInfo(alwaysAllow, true, outputSlots));
        List<IInventorySlot> ioSlots = new ArrayList<>(inputSlots);
        ioSlots.addAll(outputSlots);
        itemConfig.addSlotInfo(DataType.INPUT_OUTPUT, new InventorySlotInfo(true, true, ioSlots));
        itemConfig.addSlotInfo(DataType.ENERGY, new InventorySlotInfo(true, true, energySlot));
        // Set default config directions
        itemConfig.setDefaults();
    }
    return itemConfig;
}
Also used : IInventorySlot(mekanism.api.inventory.IInventorySlot) ArrayList(java.util.ArrayList) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) InventorySlotInfo(mekanism.common.tile.component.config.slot.InventorySlotInfo)

Example 9 with ConfigInfo

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

the class TileComponentConfig method readFromUpdateTag.

@Override
public void readFromUpdateTag(CompoundNBT updateTag) {
    if (updateTag.contains(NBTConstants.COMPONENT_CONFIG, NBT.TAG_COMPOUND)) {
        CompoundNBT configNBT = updateTag.getCompound(NBTConstants.COMPONENT_CONFIG);
        for (Entry<TransmissionType, ConfigInfo> entry : configInfo.entrySet()) {
            TransmissionType type = entry.getKey();
            ConfigInfo info = entry.getValue();
            CompoundNBT sideConfig = configNBT.getCompound(NBTConstants.CONFIG + type.ordinal());
            for (RelativeSide side : EnumUtils.SIDES) {
                NBTUtils.setEnumIfPresent(sideConfig, NBTConstants.SIDE + side.ordinal(), DataType::byIndexStatic, dataType -> info.setDataType(dataType, side));
            }
        }
    }
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) TransmissionType(mekanism.common.lib.transmitter.TransmissionType) RelativeSide(mekanism.api.RelativeSide) DataType(mekanism.common.tile.component.config.DataType) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo)

Example 10 with ConfigInfo

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

the class TileComponentEjector method tickServer.

public void tickServer() {
    for (Map.Entry<TransmissionType, ConfigInfo> entry : configInfo.entrySet()) {
        TransmissionType type = entry.getKey();
        ConfigInfo info = entry.getValue();
        if (info.isEjecting() && (canEject == null || canEject.test(type))) {
            if (type == TransmissionType.ITEM) {
                if (tickDelay == 0) {
                    outputItems(info);
                } else {
                    tickDelay--;
                }
            } else if (type != TransmissionType.HEAT) {
                eject(type, info);
            }
        }
    }
}
Also used : TransmissionType(mekanism.common.lib.transmitter.TransmissionType) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap)

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