Search in sources :

Example 1 with TransporterUtils

use of mekanism.common.util.TransporterUtils in project Mekanism by mekanism.

the class TileComponentEjector method read.

@Override
public void read(CompoundNBT nbtTags) {
    if (nbtTags.contains(NBTConstants.COMPONENT_EJECTOR, NBT.TAG_COMPOUND)) {
        CompoundNBT ejectorNBT = nbtTags.getCompound(NBTConstants.COMPONENT_EJECTOR);
        strictInput = ejectorNBT.getBoolean(NBTConstants.STRICT_INPUT);
        NBTUtils.setEnumIfPresent(ejectorNBT, NBTConstants.COLOR, TransporterUtils::readColor, color -> outputColor = color);
        // Input colors
        for (int i = 0; i < EnumUtils.DIRECTIONS.length; i++) {
            int index = i;
            NBTUtils.setEnumIfPresent(ejectorNBT, NBTConstants.COLOR + index, TransporterUtils::readColor, color -> inputColors[index] = color);
        }
    }
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) TransporterUtils(mekanism.common.util.TransporterUtils)

Example 2 with TransporterUtils

use of mekanism.common.util.TransporterUtils in project Mekanism by mekanism.

the class TileEntityLogisticalSorter method loadGeneralPersistentData.

@Override
protected void loadGeneralPersistentData(CompoundNBT data) {
    super.loadGeneralPersistentData(data);
    NBTUtils.setEnumIfPresent(data, NBTConstants.COLOR, TransporterUtils::readColor, color -> this.color = color);
    autoEject = data.getBoolean(NBTConstants.EJECT);
    roundRobin = data.getBoolean(NBTConstants.ROUND_ROBIN);
    singleItem = data.getBoolean(NBTConstants.SINGLE_ITEM);
    filters.clear();
    if (data.contains(NBTConstants.FILTERS, NBT.TAG_LIST)) {
        ListNBT tagList = data.getList(NBTConstants.FILTERS, NBT.TAG_COMPOUND);
        for (int i = 0; i < tagList.size(); i++) {
            IFilter<?> filter = BaseFilter.readFromNBT(tagList.getCompound(i));
            if (filter instanceof SorterFilter) {
                filters.add((SorterFilter<?>) filter);
            }
        }
    }
}
Also used : SorterFilter(mekanism.common.content.transporter.SorterFilter) ListNBT(net.minecraft.nbt.ListNBT) TransporterUtils(mekanism.common.util.TransporterUtils)

Aggregations

TransporterUtils (mekanism.common.util.TransporterUtils)2 SorterFilter (mekanism.common.content.transporter.SorterFilter)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 ListNBT (net.minecraft.nbt.ListNBT)1