use of blusunrize.immersiveengineering.common.util.inventory.IEItemStackHandler in project ImmersiveEngineering by BluSunrize.
the class ContainerRevolver method onContainerClosed.
@Override
public void onContainerClosed(EntityPlayer par1EntityPlayer) {
super.onContainerClosed(par1EntityPlayer);
for (int hand = 0; hand < (this.secondHand != null ? 2 : 1); hand++) {
IItemHandler secondRevolverInventory = secondRevolver.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
IItemHandler inv = this.secondHand == null ? this.inv : (hand == 0) == (player.getPrimaryHand() == EnumHandSide.RIGHT) ? secondRevolverInventory : this.inv;
if (inv instanceof IEItemStackHandler)
((IEItemStackHandler) inv).setInventoryForUpdate(null);
}
}
use of blusunrize.immersiveengineering.common.util.inventory.IEItemStackHandler in project ImmersiveEngineering by BluSunrize.
the class ContainerModWorkbench method rebindSlots.
public void rebindSlots() {
// Don't rebind if the tool didn't change
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
for (Slot slot : inventorySlots) if (slot instanceof IESlot.Upgrades)
if (ItemStack.areItemsEqual(((IESlot.Upgrades) slot).upgradeableTool, inv.getStackInSlot(0)))
return;
this.inventorySlots.clear();
this.inventoryItemStacks.clear();
this.addSlotToContainer(new IESlot.ModWorkbench(this, this.inv, 0, 24, 22, 1));
slotCount = 1;
ItemStack tool = this.getSlot(0).getStack();
if (tool.getItem() instanceof IUpgradeableTool) {
IItemHandler handler = tool.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (handler instanceof IEItemStackHandler)
((IEItemStackHandler) handler).setTile(tile);
Slot[] slots = ((IUpgradeableTool) tool.getItem()).getWorkbenchSlots(this, tool);
if (slots != null)
for (Slot s : slots) {
this.addSlotToContainer(s);
slotCount++;
}
if (tool.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) {
ShaderWrapper wrapper = tool.getCapability(CapabilityShader.SHADER_CAPABILITY, null);
if (wrapper != null) {
this.shaderInv = new InventoryShader(this, wrapper);
this.addSlotToContainer(new IESlot.Shader(this, shaderInv, 0, 130, 32, tool));
slotCount++;
this.shaderInv.shader = wrapper.getShaderItem();
}
}
} else if (!(tool.getItem() instanceof IConfigurableTool)) {
boolean blueprint = false;
if (tool.getItem() instanceof ItemEngineersBlueprint) {
// Init the output inventory
blueprint = true;
BlueprintCraftingRecipe[] recipes = ((ItemEngineersBlueprint) tool.getItem()).getRecipes(tool);
inventoryBPoutput = new InventoryBlueprint(this, recipes);
// Add output slots
for (int i = 0; i < recipes.length; i++) {
int y = 21 + (i < 9 ? i / 3 : (-(i - 6) / 3)) * 18;
this.addSlotToContainer(new IESlot.BlueprintOutput(this, inventoryBPoutput, this.inv, i, 118 + (i % 3 * 18), y, recipes[i]));
slotCount++;
}
}
// Add input slots, these are always here if no tool is in
for (int i = 0; i < 6; i++) {
if (blueprint)
this.addSlotToContainer(new IESlot.BlueprintInput(this, this.inv, this.inventoryBPoutput, i + 1, i % 2 == 0 ? 74 : 92, 21 + (i / 2) * 18));
else
this.addSlotToContainer(new Slot(this.inv, i + 1, i % 2 == 0 ? 74 : 92, 21 + (i / 2) * 18));
slotCount++;
}
}
bindPlayerInv(inventoryPlayer);
ImmersiveEngineering.proxy.reInitGui();
}
use of blusunrize.immersiveengineering.common.util.inventory.IEItemStackHandler in project ImmersiveEngineering by BluSunrize.
the class ContainerRevolver method addSlots.
@Override
int addSlots() {
if (this.equipmentSlot == EntityEquipmentSlot.MAINHAND || this.equipmentSlot == EntityEquipmentSlot.OFFHAND) {
int bullets0 = ((IBulletContainer) (heldItem).getItem()).getBulletCount(heldItem);
this.secondHand = this.equipmentSlot == EntityEquipmentSlot.MAINHAND ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND;
this.secondRevolver = this.player.getItemStackFromSlot(this.secondHand);
if (!secondRevolver.isEmpty() && secondRevolver.getItem() instanceof IBulletContainer) {
int bullets1 = ((IBulletContainer) secondRevolver.getItem()).getBulletCount(secondRevolver);
this.offset = ((bullets0 >= 18 ? 150 : bullets0 > 8 ? 136 : 74) + (bullets1 >= 18 ? 150 : bullets1 > 8 ? 136 : 74) + 4 - 176) / 2;
} else {
this.secondRevolver = ItemStack.EMPTY;
this.secondHand = null;
this.offset = ((bullets0 >= 18 ? 150 : bullets0 > 8 ? 136 : 74) - 176) / 2;
}
}
int total = 0;
int off = (offset < 0 ? -offset : 0);
for (int hand = 0; hand < (this.secondHand != null ? 2 : 1); hand++) {
int i = 0;
ItemStack held = this.secondHand == null ? heldItem : (hand == 0) == (player.getPrimaryHand() == EnumHandSide.RIGHT) ? secondRevolver : heldItem;
IItemHandler secondRevolverInventory = secondRevolver.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
IItemHandler inv = this.secondHand == null ? this.inv : (hand == 0) == (player.getPrimaryHand() == EnumHandSide.RIGHT) ? secondRevolverInventory : this.inv;
int revolverSlots = ((IBulletContainer) (held).getItem()).getBulletCount(held);
if (inv instanceof IEItemStackHandler)
((IEItemStackHandler) inv).setInventoryForUpdate(this.inventoryPlayer);
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 29, 3, 1));
int slots = revolverSlots >= 18 ? 2 : revolverSlots > 8 ? 1 : 0;
for (int[] slot : slotPositions[slots]) this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + slot[0], slot[1], 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 48, 49, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 29, 57, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 10, 49, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 2, 30, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 10, 11, 1));
off += (revolverSlots >= 18 ? 150 : revolverSlots > 8 ? 136 : 74) + 4;
total += i;
}
this.bindPlayerInventory(this.inventoryPlayer);
return total;
}
Aggregations