use of blusunrize.immersiveengineering.api.tool.IUpgradeableTool in project ImmersiveEngineering by BluSunrize.
the class ContainerModWorkbench method rebindSlots.
public void rebindSlots() {
this.inventorySlots.clear();
this.addSlotToContainer(new IESlot.UpgradeableItem(this, this.inv, 0, 24, 22, 1));
slotCount = 1;
ItemStack tool = this.getSlot(0).getStack();
if (tool != null) {
if (tool.getItem() instanceof IUpgradeableTool) {
if (tool.getItem() instanceof ItemEngineersBlueprint)
((ItemEngineersBlueprint) tool.getItem()).updateOutputs(tool);
this.toolInv = new InventoryStorageItem(this, tool);
Slot[] slots = ((IUpgradeableTool) tool.getItem()).getWorkbenchSlots(this, tool, toolInv);
if (slots != null)
for (Slot s : slots) {
this.addSlotToContainer(s);
slotCount++;
}
ItemStack[] cont = ((IUpgradeableTool) tool.getItem()).getContainedItems(tool);
this.toolInv.stackList = cont;
}
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();
}
}
}
bindPlayerInv(inventoryPlayer);
ImmersiveEngineering.proxy.reInitGui();
}
use of blusunrize.immersiveengineering.api.tool.IUpgradeableTool in project ImmersiveEngineering by BluSunrize.
the class ContainerModWorkbench method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = inventorySlots.get(slot);
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if (slot < slotCount) {
if (!this.mergeItemStack(stackInSlot, slotCount, (slotCount + 36), true))
return null;
} else if (stackInSlot != null) {
if (stackInSlot.getItem() instanceof IUpgradeableTool && ((IUpgradeableTool) stackInSlot.getItem()).canModify(stackInSlot)) {
if (!this.mergeItemStack(stackInSlot, 0, 1, true))
return null;
} else if (stackInSlot.getItem() instanceof IConfigurableTool && ((IConfigurableTool) stackInSlot.getItem()).canConfigure(stackInSlot)) {
if (!this.mergeItemStack(stackInSlot, 0, 1, true))
return null;
} else if (slotCount > 1) {
boolean b = true;
for (int i = 1; i < slotCount; i++) {
Slot s = inventorySlots.get(i);
if (s != null && s.isItemValid(stackInSlot))
if (this.mergeItemStack(stackInSlot, i, i + 1, true)) {
b = false;
break;
} else
continue;
}
if (b)
return null;
}
}
if (stackInSlot.stackSize == 0)
slotObject.putStack(null);
else
slotObject.onSlotChanged();
if (stackInSlot.stackSize == stack.stackSize)
return null;
slotObject.onPickupFromSlot(player, stack);
}
return stack;
}
Aggregations