Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package qwertyasdef.alchemtrans.inventory;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.inventory.Slot;
- import net.minecraft.item.ItemStack;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import qwertyasdef.alchemtrans.tile.TileNetherrackBoiler;
- public class ContainerNetherrackBoiler extends Container {
- private TileNetherrackBoiler tileEntity;
- public ContainerNetherrackBoiler(IInventory playerInv, TileNetherrackBoiler tileEntity) {
- this.tileEntity = tileEntity;
- /*
- SLOTS:
- Tile Entity: 0-2
- Player Inventory: 3-29
- Player Hotbar: 30-38
- */
- // Fluid container input
- this.addSlotToContainer(new Slot(tileEntity, 0, 44, 17));
- // Fluid container output
- this.addSlotToContainer(new Slot(tileEntity, 1, 44, 48));
- // Smelting output
- this.addSlotToContainer(new Slot(tileEntity, 2, 133, 35));
- // Player inventory
- for (int i = 0; i < 3; ++i){
- for (int j = 0; j < 9; ++j) {
- this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
- }
- }
- // Player hotbar
- for (int k = 0; k < 9; ++k){
- this.addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 142));
- }
- }
- @Override
- public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
- ItemStack previous = ItemStack.EMPTY;
- Slot slot = this.inventorySlots.get(fromSlot);
- if (slot != null && slot.getHasStack()) {
- ItemStack current = slot.getStack();
- previous = current.copy();
- // [...] Custom behaviour
- if (fromSlot < 3) {
- // From TE Inventory to Player Inventory
- if (!this.mergeItemStack(current, 2, 38, true)) {
- return ItemStack.EMPTY;
- }
- } else {
- // From Player Inventory to TE Inventory
- if (!this.mergeItemStack(current, 0, 1, false)) {
- return ItemStack.EMPTY;
- }
- }
- if (current.isEmpty()) {
- slot.putStack(ItemStack.EMPTY);
- } else {
- slot.onSlotChanged();
- }
- }
- return previous;
- }
- @Override
- public boolean canInteractWith(EntityPlayer playerIn) {
- return true;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void updateProgressBar(int id, int data) {
- this.tileEntity.setField(id, data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement