Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.arucraft.container;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.ICrafting;
- import net.minecraft.inventory.Slot;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.crafting.FurnaceRecipes;
- import net.minecraft.tileentity.TileEntityFurnace;
- import com.arucraft.slot.SlotAlloyOven;
- import com.arucraft.tileentity.TileEntityAlloyOven;
- public class ContainerAlloyOven extends Container {
- private TileEntityAlloyOven oven;
- private int tripCookTime;
- private int tripPower;
- private int lastItemBurnTime;
- public ContainerAlloyOven(InventoryPlayer invPlayer, TileEntityAlloyOven teAlloyOven) {
- tripCookTime = 0;
- tripPower = 0;
- lastItemBurnTime = 0;
- oven = teAlloyOven;
- this.addSlotToContainer(new Slot(teAlloyOven, 0, 44, 16));
- this.addSlotToContainer(new Slot(teAlloyOven, 1, 44, 35));
- this.addSlotToContainer(new Slot(teAlloyOven, 2, 44, 54));
- this.addSlotToContainer(new Slot(teAlloyOven, 3, 8, 55));
- this.addSlotToContainer(new SlotAlloyOven(invPlayer.player, teAlloyOven, 4, 124, 35));
- //Inventory
- for(int i = 0; i < 3; i++) {
- for(int j = 0; j < 9; j++) {
- this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
- }
- }
- //ActionBar
- for(int i = 0; i < 9; i++) {
- this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));
- }
- }
- public void addCraftingToCrafters (ICrafting icraft) {
- super.addCraftingToCrafters(icraft);
- icraft.sendProgressBarUpdate(this, 0, this.oven.tripCooktime);
- icraft.sendProgressBarUpdate(this, 1, this.oven.tripPower);
- }
- public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_)
- {
- ItemStack itemstack = null;
- Slot slot = (Slot)this.inventorySlots.get(p_82846_2_);
- if (slot != null && slot.getHasStack())
- {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- if (p_82846_2_ == 2)
- {
- if (!this.mergeItemStack(itemstack1, 3, 39, true))
- {
- return null;
- }
- slot.onSlotChange(itemstack1, itemstack);
- }
- else if (p_82846_2_ != 1 && p_82846_2_ != 0)
- {
- if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null)
- {
- if (!this.mergeItemStack(itemstack1, 0, 1, false))
- {
- return null;
- }
- }
- else if (TileEntityFurnace.isItemFuel(itemstack1))
- {
- if (!this.mergeItemStack(itemstack1, 1, 2, false))
- {
- return null;
- }
- }
- else if (p_82846_2_ >= 3 && p_82846_2_ < 30)
- {
- if (!this.mergeItemStack(itemstack1, 30, 39, false))
- {
- return null;
- }
- }
- else if (p_82846_2_ >= 30 && p_82846_2_ < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
- {
- return null;
- }
- }
- else if (!this.mergeItemStack(itemstack1, 3, 39, false))
- {
- return null;
- }
- if (itemstack1.stackSize == 0)
- {
- slot.putStack((ItemStack)null);
- }
- else
- {
- slot.onSlotChanged();
- }
- if (itemstack1.stackSize == itemstack.stackSize)
- {
- return null;
- }
- slot.onPickupFromSlot(p_82846_1_, itemstack1);
- }
- return itemstack;
- }
- @Override
- public boolean canInteractWith(EntityPlayer player) {
- return oven.isUseableByPlayer(player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment