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);
}
}
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;
}
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;
}
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));
}
}
}
}
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);
}
}
}
}
Aggregations