Search in sources :

Example 1 with InventorySlotHelper

use of mekanism.common.capabilities.holder.slot.InventorySlotHelper 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();
}
Also used : SyncableInt(mekanism.common.inventory.container.sync.SyncableInt) IEnergyContainerHolder(mekanism.common.capabilities.holder.energy.IEnergyContainerHolder) IBoundingBlock(mekanism.common.tile.interfaces.IBoundingBlock) CompoundNBT(net.minecraft.nbt.CompoundNBT) WrappingComputerMethod(mekanism.common.integration.computer.annotation.WrappingComputerMethod) Direction(net.minecraft.util.Direction) Block(net.minecraft.block.Block) Capabilities(mekanism.common.capabilities.Capabilities) Object2ObjectOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) Map(java.util.Map) BasicCapabilityResolver(mekanism.common.capabilities.resolver.BasicCapabilityResolver) MekanismBlocks(mekanism.common.registries.MekanismBlocks) ListNBT(net.minecraft.nbt.ListNBT) TileEntityLogisticalTransporterBase(mekanism.common.tile.transmitter.TileEntityLogisticalTransporterBase) IChunkLoader(mekanism.common.lib.chunkloading.IChunkLoader) BlockEvent(net.minecraftforge.event.world.BlockEvent) EnergyInventorySlot(mekanism.common.inventory.slot.EnergyInventorySlot) NBTUtils(mekanism.common.util.NBTUtils) MinerEnergyContainer(mekanism.common.capabilities.energy.MinerEnergyContainer) Set(java.util.Set) MekanismUtils(mekanism.common.util.MekanismUtils) State(mekanism.common.content.miner.ThreadMinerSearch.State) ComputerException(mekanism.common.integration.computer.ComputerException) InventoryUtils(mekanism.common.util.InventoryUtils) RelativeSide(mekanism.api.RelativeSide) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) IFilter(mekanism.common.content.filter.IFilter) ForgeRegistries(net.minecraftforge.registries.ForgeRegistries) EnergyContainerHelper(mekanism.common.capabilities.holder.energy.EnergyContainerHelper) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) SyncableBoolean(mekanism.common.inventory.container.sync.SyncableBoolean) ArrayList(java.util.ArrayList) LazyOptional(net.minecraftforge.common.util.LazyOptional) ItemStack(net.minecraft.item.ItemStack) LootContext(net.minecraft.loot.LootContext) ItemHandlerHelper(net.minecraftforge.items.ItemHandlerHelper) TransitResponse(mekanism.common.lib.inventory.TransitRequest.TransitResponse) ObjectIterator(it.unimi.dsi.fastutil.objects.ObjectIterator) DigitalMinerConfigContainer(mekanism.common.inventory.container.tile.DigitalMinerConfigContainer) Nullable(javax.annotation.Nullable) Long2ObjectMaps(it.unimi.dsi.fastutil.longs.Long2ObjectMaps) SyncableEnum(mekanism.common.inventory.container.sync.SyncableEnum) ISustainedData(mekanism.common.tile.interfaces.ISustainedData) SyncableItemStack(mekanism.common.inventory.container.sync.SyncableItemStack) BlockPos(net.minecraft.util.math.BlockPos) MinerFilter(mekanism.common.content.miner.MinerFilter) SyncableFilterList(mekanism.common.inventory.container.sync.list.SyncableFilterList) MekFakePlayer(mekanism.common.base.MekFakePlayer) MinecraftForge(net.minecraftforge.common.MinecraftForge) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap) MekanismTags(mekanism.common.tags.MekanismTags) TileEntity(net.minecraft.tileentity.TileEntity) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) IInventorySlotHolder(mekanism.common.capabilities.holder.slot.IInventorySlotHolder) Finder(mekanism.common.lib.inventory.Finder) Action(mekanism.api.Action) SyncableRegistryEntry(mekanism.common.inventory.container.sync.SyncableRegistryEntry) ServerWorld(net.minecraft.world.server.ServerWorld) EnergyCompatUtils(mekanism.common.integration.energy.EnergyCompatUtils) Item(net.minecraft.item.Item) ThreadMinerSearch(mekanism.common.content.miner.ThreadMinerSearch) AutomationType(mekanism.api.inventory.AutomationType) ComputerIInventorySlotWrapper(mekanism.common.integration.computer.SpecialComputerMethodWrapper.ComputerIInventorySlotWrapper) InventorySlotHelper(mekanism.common.capabilities.holder.slot.InventorySlotHelper) ItemDataUtils(mekanism.common.util.ItemDataUtils) ITileFilterHolder(mekanism.common.tile.interfaces.ITileFilterHolder) WorldEvents(net.minecraftforge.common.util.Constants.WorldEvents) Enchantments(net.minecraft.enchantment.Enchantments) HashList(mekanism.common.lib.collection.HashList) Region(net.minecraft.world.Region) TileComponentChunkLoader(mekanism.common.tile.component.TileComponentChunkLoader) BlockState(net.minecraft.block.BlockState) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) IHasSortableFilters(mekanism.common.tile.interfaces.IHasSortableFilters) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Predicate(java.util.function.Predicate) StackUtils(mekanism.common.util.StackUtils) LootParameters(net.minecraft.loot.LootParameters) ChunkPos(net.minecraft.util.math.ChunkPos) Capability(net.minecraftforge.common.capabilities.Capability) Objects(java.util.Objects) List(java.util.List) BaseFilter(mekanism.common.content.filter.BaseFilter) Vector3d(net.minecraft.util.math.vector.Vector3d) NBTConstants(mekanism.api.NBTConstants) Optional(java.util.Optional) Vector3i(net.minecraft.util.math.vector.Vector3i) MekanismContainer(mekanism.common.inventory.container.MekanismContainer) Upgrade(mekanism.api.Upgrade) ObjectArraySet(it.unimi.dsi.fastutil.objects.ObjectArraySet) BasicInventorySlot(mekanism.common.inventory.slot.BasicInventorySlot) ITextComponent(net.minecraft.util.text.ITextComponent) BiPredicate(java.util.function.BiPredicate) FloatingLong(mekanism.api.math.FloatingLong) ComputerMethod(mekanism.common.integration.computer.annotation.ComputerMethod) TransitRequest(mekanism.common.lib.inventory.TransitRequest) MekanismItems(mekanism.common.registries.MekanismItems) Nonnull(javax.annotation.Nonnull) NonNull(mekanism.api.annotations.NonNull) TileEntityMekanism(mekanism.common.tile.base.TileEntityMekanism) Items(net.minecraft.item.Items) ObjectOpenHashSet(it.unimi.dsi.fastutil.objects.ObjectOpenHashSet) NBT(net.minecraftforge.common.util.Constants.NBT) IInventorySlot(mekanism.api.inventory.IInventorySlot) WorldUtils(mekanism.common.util.WorldUtils) BitSet(java.util.BitSet) Collections(java.util.Collections) MekanismConfig(mekanism.common.config.MekanismConfig) UpgradeUtils(mekanism.common.util.UpgradeUtils) InventorySlotHelper(mekanism.common.capabilities.holder.slot.InventorySlotHelper) AutomationType(mekanism.api.inventory.AutomationType) BasicInventorySlot(mekanism.common.inventory.slot.BasicInventorySlot) ItemStack(net.minecraft.item.ItemStack) SyncableItemStack(mekanism.common.inventory.container.sync.SyncableItemStack) Nonnull(javax.annotation.Nonnull)

Example 2 with InventorySlotHelper

use of mekanism.common.capabilities.holder.slot.InventorySlotHelper in project Mekanism by mekanism.

the class TileEntityChemicalWasher method getInitialInventory.

@Nonnull
@Override
protected IInventorySlotHolder getInitialInventory() {
    InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig);
    builder.addSlot(fluidSlot = FluidInventorySlot.fill(fluidTank, this, 180, 71));
    // Output slot for the fluid container that was used as an input
    builder.addSlot(fluidOutputSlot = OutputInventorySlot.at(this, 180, 102));
    builder.addSlot(slurryOutputSlot = SlurryInventorySlot.drain(outputTank, this, 152, 56));
    builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, this, 152, 14));
    slurryOutputSlot.setSlotOverlay(SlotOverlay.MINUS);
    fluidSlot.setSlotType(ContainerSlotType.INPUT);
    return builder.build();
}
Also used : InventorySlotHelper(mekanism.common.capabilities.holder.slot.InventorySlotHelper) Nonnull(javax.annotation.Nonnull)

Example 3 with InventorySlotHelper

use of mekanism.common.capabilities.holder.slot.InventorySlotHelper in project Mekanism by mekanism.

the class TileEntityCombiner method getInitialInventory.

@Nonnull
@Override
protected IInventorySlotHolder getInitialInventory() {
    InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig);
    builder.addSlot(mainInputSlot = InputInventorySlot.at(item -> containsRecipeAB(item, extraInputSlot.getStack()), this::containsRecipeA, recipeCacheLookupMonitor, 64, 17));
    builder.addSlot(extraInputSlot = InputInventorySlot.at(item -> containsRecipeBA(mainInputSlot.getStack(), item), this::containsRecipeB, recipeCacheLookupMonitor, 64, 53));
    builder.addSlot(outputSlot = OutputInventorySlot.at(this, 116, 35));
    builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, this, 39, 35));
    extraInputSlot.setSlotType(ContainerSlotType.EXTRA);
    return builder.build();
}
Also used : InventorySlotHelper(mekanism.common.capabilities.holder.slot.InventorySlotHelper) Nonnull(javax.annotation.Nonnull)

Example 4 with InventorySlotHelper

use of mekanism.common.capabilities.holder.slot.InventorySlotHelper in project Mekanism by mekanism.

the class TileEntityChemicalCrystallizer method getInitialInventory.

@Nonnull
@Override
protected IInventorySlotHolder getInitialInventory() {
    InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig);
    builder.addSlot(inputSlot = MergedChemicalInventorySlot.fill(inputTank, this, 8, 65));
    builder.addSlot(outputSlot = OutputInventorySlot.at(this, 129, 57));
    builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, this, 152, 5));
    inputSlot.setSlotOverlay(SlotOverlay.PLUS);
    return builder.build();
}
Also used : InventorySlotHelper(mekanism.common.capabilities.holder.slot.InventorySlotHelper) Nonnull(javax.annotation.Nonnull)

Example 5 with InventorySlotHelper

use of mekanism.common.capabilities.holder.slot.InventorySlotHelper in project Mekanism by mekanism.

the class TileEntityGasGenerator method getInitialInventory.

@Nonnull
@Override
protected IInventorySlotHolder getInitialInventory() {
    InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection);
    builder.addSlot(fuelSlot = GasInventorySlot.fill(fuelTank, this, 17, 35), RelativeSide.FRONT, RelativeSide.LEFT, RelativeSide.BACK, RelativeSide.TOP, RelativeSide.BOTTOM);
    builder.addSlot(energySlot = EnergyInventorySlot.drain(getEnergyContainer(), this, 143, 35), RelativeSide.RIGHT);
    fuelSlot.setSlotOverlay(SlotOverlay.MINUS);
    return builder.build();
}
Also used : InventorySlotHelper(mekanism.common.capabilities.holder.slot.InventorySlotHelper) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)45 InventorySlotHelper (mekanism.common.capabilities.holder.slot.InventorySlotHelper)45 BiPredicate (java.util.function.BiPredicate)2 NonNull (mekanism.api.annotations.NonNull)2 AutomationType (mekanism.api.inventory.AutomationType)2 IInventorySlot (mekanism.api.inventory.IInventorySlot)2 IInventorySlotHolder (mekanism.common.capabilities.holder.slot.IInventorySlotHolder)2 OutputInventorySlot (mekanism.common.inventory.slot.OutputInventorySlot)2 Item (net.minecraft.item.Item)2 Int2ObjectMap (it.unimi.dsi.fastutil.ints.Int2ObjectMap)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 IntList (it.unimi.dsi.fastutil.ints.IntList)1 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)1 Long2ObjectMaps (it.unimi.dsi.fastutil.longs.Long2ObjectMaps)1 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)1 ObjectArraySet (it.unimi.dsi.fastutil.objects.ObjectArraySet)1 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)1 ObjectOpenHashSet (it.unimi.dsi.fastutil.objects.ObjectOpenHashSet)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1