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;
}
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;
}
}
}
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);
}
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;
}
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;
}
Aggregations