use of mekanism.common.capabilities.holder.slot.IInventorySlotHolder in project Mekanism by mekanism.
the class TileEntityDigitalMiner method getInitialInventory.
@Nonnull
@Override
protected IInventorySlotHolder getInitialInventory() {
mainSlots = new ArrayList<>();
InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection, side -> side == RelativeSide.TOP, side -> side == RelativeSide.BACK);
// Allow insertion manually or internally, or if it is a replace stack
BiPredicate<@NonNull ItemStack, @NonNull AutomationType> canInsert = (stack, automationType) -> automationType != AutomationType.EXTERNAL || isReplaceTarget(stack.getItem());
// Allow extraction if it is manual or if it is a replace stack
BiPredicate<@NonNull ItemStack, @NonNull AutomationType> canExtract = (stack, automationType) -> automationType == AutomationType.MANUAL || !isReplaceTarget(stack.getItem());
for (int slotY = 0; slotY < 3; slotY++) {
for (int slotX = 0; slotX < 9; slotX++) {
BasicInventorySlot slot = BasicInventorySlot.at(canExtract, canInsert, this, 8 + slotX * 18, 92 + slotY * 18);
builder.addSlot(slot, RelativeSide.BACK, RelativeSide.TOP);
mainSlots.add(slot);
}
}
builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, this, 152, 20));
return builder.build();
}
use of mekanism.common.capabilities.holder.slot.IInventorySlotHolder in project Mekanism by mekanism.
the class TileEntityPersonalChest method getInitialInventory.
@Nonnull
@Override
protected IInventorySlotHolder getInitialInventory() {
InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection);
// Note: We always allow manual interaction (even for insertion), as if a player has the GUI open we treat that as they are allowed to interact with it
// and if the security mode changes we then boot any players who can't interact with it anymore out of the GUI
BiPredicate<@NonNull ItemStack, @NonNull AutomationType> canInteract = (stack, automationType) -> automationType == AutomationType.MANUAL || SecurityUtils.getSecurity(this, Dist.DEDICATED_SERVER) == SecurityMode.PUBLIC;
for (int slotY = 0; slotY < 6; slotY++) {
for (int slotX = 0; slotX < 9; slotX++) {
// Note: we allow access to the slots from all sides as long as it is public, unlike in 1.12 where we always denied the bottom face
// We did that to ensure that things like hoppers that could check IInventory did not bypass any restrictions
builder.addSlot(BasicInventorySlot.at(canInteract, canInteract, this, 8 + slotX * 18, 26 + slotY * 18));
}
}
return builder.build();
}
Aggregations