Search in sources :

Example 81 with IInventory

use of net.minecraft.inventory.IInventory in project PneumaticCraft by MineMaarten.

the class RenderSearchItemBlock method getSearchedItemCount.

private int getSearchedItemCount() {
    if (world.getTileEntity(blockX, blockY, blockZ) instanceof IInventory) {
        int itemCount = 0;
        IInventory inventory = (IInventory) world.getTileEntity(blockX, blockY, blockZ);
        ItemStack searchStack = ItemPneumaticArmor.getSearchedStack(FMLClientHandler.instance().getClient().thePlayer.getCurrentArmor(3));
        if (searchStack == null)
            return 0;
        for (int l = 0; l < inventory.getSizeInventory(); l++) {
            if (inventory.getStackInSlot(l) != null) {
                itemCount += getSearchedItemCount(inventory.getStackInSlot(l), searchStack);
            }
        }
        return itemCount;
    }
    return 0;
}
Also used : IInventory(net.minecraft.inventory.IInventory) ItemStack(net.minecraft.item.ItemStack)

Example 82 with IInventory

use of net.minecraft.inventory.IInventory in project PneumaticCraft by MineMaarten.

the class ModuleCharging method update.

@Override
public void update() {
    super.update();
    IInventory inv = getConnectedInventory();
    if (inv != null) {
        int[] accessibleSlots = IOHelper.getAccessibleSlotsForInventory(inv, dir.getOpposite());
        for (int i = 0; i < (upgraded ? 10 : 1) * PneumaticValues.CHARGING_STATION_CHARGE_RATE; i++) {
            boolean charged = false;
            for (int slot : accessibleSlots) {
                ItemStack chargedItem = inv.getStackInSlot(slot);
                if (chargedItem != null && chargedItem.getItem() instanceof IPressurizable) {
                    IPressurizable chargingItem = (IPressurizable) chargedItem.getItem();
                    IAirHandler airHandler = ((IPneumaticMachine) pressureTube).getAirHandler();
                    if (chargingItem.getPressure(chargedItem) > airHandler.getPressure(ForgeDirection.UNKNOWN) + 0.01F && chargingItem.getPressure(chargedItem) > 0F) {
                        chargingItem.addAir(chargedItem, -1);
                        airHandler.addAir(1, ForgeDirection.UNKNOWN);
                        charged = true;
                    } else if (chargingItem.getPressure(chargedItem) < airHandler.getPressure(ForgeDirection.UNKNOWN) - 0.01F && chargingItem.getPressure(chargedItem) < chargingItem.maxPressure(chargedItem)) {
                        // if there is pressure, and the item isn't fully charged yet..
                        chargingItem.addAir(chargedItem, 1);
                        airHandler.addAir(-1, ForgeDirection.UNKNOWN);
                        charged = true;
                    }
                }
            }
            if (!charged)
                break;
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) IPressurizable(pneumaticCraft.api.item.IPressurizable) IAirHandler(pneumaticCraft.api.tileentity.IAirHandler) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ItemStack(net.minecraft.item.ItemStack)

Example 83 with IInventory

use of net.minecraft.inventory.IInventory in project PneumaticCraft by MineMaarten.

the class ContainerAmadron method capShoppingAmount.

public int capShoppingAmount(int offerId, int wantedAmount, EntityPlayer player) {
    IInventory inv = ItemAmadronTablet.getItemProvider(player.getCurrentEquippedItem());
    IFluidHandler fluidHandler = ItemAmadronTablet.getLiquidProvider(player.getCurrentEquippedItem());
    return capShoppingAmount(offers.get(offerId), wantedAmount, inv, fluidHandler, this);
}
Also used : IInventory(net.minecraft.inventory.IInventory) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 84 with IInventory

use of net.minecraft.inventory.IInventory in project PneumaticCraft by MineMaarten.

the class ItemAmadronTablet method onItemUse.

@Override
public boolean onItemUse(ItemStack tablet, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof IFluidHandler) {
        if (!world.isRemote) {
            setLiquidProvidingLocation(tablet, x, y, z, world.provider.dimensionId);
            player.addChatComponentMessage(new ChatComponentTranslation("message.amadronTable.setLiquidProvidingLocation", x, y, z, world.provider.dimensionId, world.provider.getDimensionName()));
        }
    } else if (te instanceof IInventory) {
        if (!world.isRemote) {
            setItemProvidingLocation(tablet, x, y, z, world.provider.dimensionId);
            player.addChatComponentMessage(new ChatComponentTranslation("message.amadronTable.setItemProvidingLocation", x, y, z, world.provider.dimensionId, world.provider.getDimensionName()));
        }
    } else {
        return false;
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 85 with IInventory

use of net.minecraft.inventory.IInventory in project PneumaticCraft by MineMaarten.

the class SemiBlockRequester method amountRequested.

@Override
public int amountRequested(ItemStack stack) {
    int totalRequestingAmount = getTotalRequestedAmount(stack);
    if (totalRequestingAmount > 0) {
        IInventory inv = IOHelper.getInventoryForTE(getTileEntity());
        int count = 0;
        if (inv != null) {
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack s = inv.getStackInSlot(i);
                if (s != null && isItemEqual(s, stack)) {
                    count += s.stackSize;
                }
            }
            count += getIncomingItems(stack);
            int requested = Math.max(0, Math.min(stack.stackSize, totalRequestingAmount - count));
            return requested;
        }
    }
    return 0;
}
Also used : IInventory(net.minecraft.inventory.IInventory) IAEItemStack(appeng.api.storage.data.IAEItemStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IInventory (net.minecraft.inventory.IInventory)129 ItemStack (net.minecraft.item.ItemStack)80 TileEntity (net.minecraft.tileentity.TileEntity)59 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)21 ArrayList (java.util.ArrayList)18 ISidedInventory (net.minecraft.inventory.ISidedInventory)13 EntityItem (net.minecraft.entity.item.EntityItem)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)12 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 WorldCoordinatesWrapper (network.rs485.logisticspipes.world.WorldCoordinatesWrapper)9 AMVector3 (am2.api.math.AMVector3)8 List (java.util.List)8 SidedInventoryMinecraftAdapter (logisticspipes.utils.SidedInventoryMinecraftAdapter)8 SinkReply (logisticspipes.utils.SinkReply)8 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)8 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)7 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)7 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7 ConnectionPipeType (logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType)7