use of com.enderio.core.common.util.ArrayInventory in project EnderIO by SleepyTrousers.
the class ContainerWiredCharger method addMachineSlots.
@Override
protected void addMachineSlots(@Nonnull InventoryPlayer playerInv) {
addSlotToContainer(new InventorySlot(getInv(), 0, 75, 28));
addSlotToContainer(new InventorySlot(getInv(), 1, 126, 28));
baubles = BaublesUtil.instance().getBaubles(playerInv.player);
if (baubles != null && BaublesUtil.WhoAmI.whoAmI(playerInv.player.world) == BaublesUtil.WhoAmI.SPCLIENT) {
baubles = new ShadowInventory(baubles);
}
if (hasBaublesSlots() && (baubles == null)) {
baubles = new ArrayInventory(getBaublesSize()) {
@Override
public boolean isItemValidForSlot(int i, @Nonnull ItemStack itemstack) {
return false;
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot) {
return new ItemStack(Blocks.BARRIER);
}
@Override
@Nonnull
public ItemStack decrStackSize(int slot, int amount) {
return ItemStack.EMPTY;
}
@Override
@Nonnull
public ItemStack removeStackFromSlot(int index) {
return ItemStack.EMPTY;
}
};
}
int baublesOffset = 196;
for (final EntityEquipmentSlot slt : EntityEquipmentSlot.values()) {
if (slt.getSlotType() == Type.ARMOR) {
addSlotToContainer(new Slot(playerInv, 36 + slt.getIndex(), 6, 66 - slt.getIndex() * 18) {
@Override
public int getSlotStackLimit() {
return 1;
}
@Override
public boolean isItemValid(@Nonnull ItemStack par1ItemStack) {
if (par1ItemStack.isEmpty()) {
return false;
}
return par1ItemStack.getItem().isValidArmor(par1ItemStack, slt, playerInv.player);
}
@Override
@SideOnly(Side.CLIENT)
public String getSlotTexture() {
return ItemArmor.EMPTY_SLOT_NAMES[slt.getIndex()];
}
});
}
}
addSlotToContainer(new Slot(playerInv, 40, 6, 12 + 18 * 4) {
@Override
@Nullable
@SideOnly(Side.CLIENT)
public String getSlotTexture() {
return "minecraft:items/empty_armor_slot_shield";
}
});
if (hasBaublesSlots()) {
for (int i = 0; i < baubles.getSizeInventory(); i++) {
addSlotToContainer(new Slot(baubles, i, baublesOffset, 12 + i * 18) {
@Override
public boolean isItemValid(@Nonnull ItemStack par1ItemStack) {
return inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
}
@Override
public boolean canTakeStack(@Nonnull EntityPlayer playerIn) {
ItemStack stackInSlot = inventory.getStackInSlot(getSlotIndex());
if (stackInSlot.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) {
return false;
}
return super.canTakeStack(playerIn);
}
});
}
}
}
Aggregations