use of mekanism.common.tile.component.config.slot.InventorySlotInfo 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.slot.InventorySlotInfo in project Mekanism by mekanism.
the class TileComponentEjector method outputItems.
/**
* @apiNote Ensure that it can eject before calling this method.
*/
private void outputItems(ConfigInfo info) {
for (DataType dataType : info.getSupportedDataTypes()) {
if (!dataType.canOutput()) {
continue;
}
ISlotInfo slotInfo = info.getSlotInfo(dataType);
if (slotInfo instanceof InventorySlotInfo) {
// Validate the slot info is of the correct type
Set<Direction> outputs = info.getSidesForData(dataType);
if (!outputs.isEmpty()) {
EjectTransitRequest ejectMap = InventoryUtils.getEjectItemMap(new EjectTransitRequest(tile, outputs.iterator().next()), ((InventorySlotInfo) slotInfo).getSlots());
if (!ejectMap.isEmpty()) {
for (Direction side : outputs) {
TileEntity target = WorldUtils.getTileEntity(tile.getLevel(), tile.getBlockPos().relative(side));
if (target != null) {
// Update the side so that if/when the response uses it, it makes sure it is grabbing from the correct side
ejectMap.side = side;
// If the spot is not loaded just skip trying to eject to it
TransitResponse response;
if (target instanceof TileEntityLogisticalTransporterBase) {
response = ((TileEntityLogisticalTransporterBase) target).getTransmitter().insert(tile, ejectMap, outputColor, true, 0);
} else {
response = ejectMap.addToInventory(target, side, 0, false);
}
if (!response.isEmpty()) {
// use the items returned by the TransitResponse; will be visible next loop
response.useAll();
if (ejectMap.isEmpty()) {
// If we are out of items to eject, break
break;
}
}
}
}
}
}
}
}
tickDelay = 10;
}
use of mekanism.common.tile.component.config.slot.InventorySlotInfo in project Mekanism by mekanism.
the class TileComponentConfig method setupItemIOExtraConfig.
public ConfigInfo setupItemIOExtraConfig(IInventorySlot inputSlot, IInventorySlot outputSlot, IInventorySlot extraSlot, IInventorySlot energySlot) {
ConfigInfo itemConfig = getConfig(TransmissionType.ITEM);
if (itemConfig != null) {
itemConfig.addSlotInfo(DataType.INPUT, new InventorySlotInfo(true, false, inputSlot));
itemConfig.addSlotInfo(DataType.OUTPUT, new InventorySlotInfo(false, true, outputSlot));
itemConfig.addSlotInfo(DataType.INPUT_OUTPUT, new InventorySlotInfo(true, true, inputSlot, outputSlot));
itemConfig.addSlotInfo(DataType.EXTRA, new InventorySlotInfo(true, true, extraSlot));
itemConfig.addSlotInfo(DataType.ENERGY, new InventorySlotInfo(true, true, energySlot));
// Set default config directions
itemConfig.setDefaults();
}
return itemConfig;
}
use of mekanism.common.tile.component.config.slot.InventorySlotInfo in project Mekanism by mekanism.
the class GuiMekanismTile method getFromSlot.
private DataType getFromSlot(Slot slot) {
if (slot.index < tile.getSlots() && slot instanceof InventoryContainerSlot) {
ISideConfiguration config = (ISideConfiguration) tile;
ConfigInfo info = config.getConfig().getConfig(TransmissionType.ITEM);
if (info != null) {
Set<DataType> supportedDataTypes = info.getSupportedDataTypes();
IInventorySlot inventorySlot = ((InventoryContainerSlot) slot).getInventorySlot();
for (DataType type : supportedDataTypes) {
ISlotInfo slotInfo = info.getSlotInfo(type);
if (slotInfo instanceof InventorySlotInfo && ((InventorySlotInfo) slotInfo).hasSlot(inventorySlot)) {
return type;
}
}
}
}
return null;
}
Aggregations