use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class TileComponentEjector method eject.
/**
* @apiNote Ensure that it can eject before calling this method.
*/
private void eject(TransmissionType type, ConfigInfo info) {
// Used to keep track of tanks to what sides they output to
Map<Object, Set<Direction>> outputData = null;
for (DataType dataType : info.getSupportedDataTypes()) {
if (dataType.canOutput()) {
ISlotInfo slotInfo = info.getSlotInfo(dataType);
if (slotInfo != null) {
Set<Direction> outputSides = info.getSidesForData(dataType);
if (!outputSides.isEmpty()) {
if (outputData == null) {
// Lazy init outputData
outputData = new HashMap<>();
}
if (type.isChemical() && slotInfo instanceof ChemicalSlotInfo) {
for (IChemicalTank<?, ?> tank : ((ChemicalSlotInfo<?, ?, ?>) slotInfo).getTanks()) {
if (!tank.isEmpty() && (canTankEject == null || canTankEject.test(tank))) {
outputData.computeIfAbsent(tank, t -> EnumSet.noneOf(Direction.class)).addAll(outputSides);
}
}
} else if (type == TransmissionType.FLUID && slotInfo instanceof FluidSlotInfo) {
for (IExtendedFluidTank tank : ((FluidSlotInfo) slotInfo).getTanks()) {
if (!tank.isEmpty()) {
outputData.computeIfAbsent(tank, t -> EnumSet.noneOf(Direction.class)).addAll(outputSides);
}
}
} else if (type == TransmissionType.ENERGY && slotInfo instanceof EnergySlotInfo) {
for (IEnergyContainer container : ((EnergySlotInfo) slotInfo).getContainers()) {
if (!container.isEmpty()) {
outputData.computeIfAbsent(container, t -> EnumSet.noneOf(Direction.class)).addAll(outputSides);
}
}
}
}
}
}
}
if (outputData != null && !outputData.isEmpty()) {
for (Map.Entry<Object, Set<Direction>> entry : outputData.entrySet()) {
if (type.isChemical()) {
ChemicalUtil.emit(entry.getValue(), (IChemicalTank<?, ?>) entry.getKey(), tile, chemicalEjectRate.getAsLong());
} else if (type == TransmissionType.FLUID) {
FluidUtils.emit(entry.getValue(), (IExtendedFluidTank) entry.getKey(), tile, fluidEjectRate.getAsInt());
} else if (type == TransmissionType.ENERGY) {
IEnergyContainer container = (IEnergyContainer) entry.getKey();
CableUtils.emit(entry.getValue(), container, tile, energyEjectRate == null ? container.getMaxEnergy() : energyEjectRate.get());
}
}
}
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class TileEntityQuantumEntangloporter method setupConfig.
private <T> void setupConfig(TransmissionType type, ProxySlotInfoCreator<T> proxyCreator, Supplier<List<T>> supplier) {
ConfigInfo config = configComponent.getConfig(type);
if (config != null) {
config.addSlotInfo(DataType.INPUT, proxyCreator.create(true, false, supplier));
config.addSlotInfo(DataType.OUTPUT, proxyCreator.create(false, true, supplier));
config.addSlotInfo(DataType.INPUT_OUTPUT, proxyCreator.create(true, true, supplier));
// Set default config directions
config.fill(DataType.INPUT);
config.setDataType(DataType.OUTPUT, RelativeSide.FRONT);
}
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class TileComponentConfig method write.
@Override
public void write(CompoundNBT nbtTags) {
CompoundNBT configNBT = new CompoundNBT();
for (Entry<TransmissionType, ConfigInfo> entry : configInfo.entrySet()) {
TransmissionType type = entry.getKey();
ConfigInfo info = entry.getValue();
configNBT.putBoolean(NBTConstants.EJECT + type.ordinal(), info.isEjecting());
CompoundNBT sideConfig = new CompoundNBT();
for (RelativeSide side : EnumUtils.SIDES) {
sideConfig.putInt(NBTConstants.SIDE + side.ordinal(), info.getDataType(side).ordinal());
}
configNBT.put(NBTConstants.CONFIG + type.ordinal(), sideConfig);
}
nbtTags.put(NBTConstants.COMPONENT_CONFIG, configNBT);
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class TileComponentConfig method incrementMode.
@ComputerMethod
private void incrementMode(TransmissionType type, RelativeSide side) throws ComputerException {
tile.validateSecurityIsPublic();
validateSupportedTransmissionType(type);
ConfigInfo configInfo = this.configInfo.get(type);
if (configInfo.getDataType(side) != configInfo.incrementDataType(side)) {
sideChanged(type, side);
}
}
use of mekanism.common.tile.component.config.ConfigInfo in project Mekanism by mekanism.
the class TileComponentConfig method addSupported.
public void addSupported(TransmissionType type) {
if (!configInfo.containsKey(type)) {
configInfo.put(type, new ConfigInfo(tile::getDirection));
transmissionTypes.add(type);
}
}
Aggregations