Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vognersmods.fleshworks;
- import java.util.ArrayList;
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Set;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.inventory.InventoryCraftResult;
- import net.minecraft.inventory.InventoryCrafting;
- import net.minecraft.inventory.Slot;
- import net.minecraft.inventory.SlotCrafting;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.crafting.CraftingManager;
- import net.minecraft.world.World;
- public class ContainerBolus extends Container
- {
- /** The crafting matrix inventory (3x3). */
- public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
- public IInventory craftResult = new InventoryCraftResult();
- private World worldObj;
- private int posX;
- public int posY;
- private int posZ;
- TileEntityBolus teBolus;
- private short transactionID;
- private int field_94535_f = -1;
- private int field_94536_g;
- private final Set field_94537_h = new HashSet();
- /** list of all people that need to be notified when this craftinventory changes */
- protected List crafters = new ArrayList();
- private Set playerList = new HashSet();
- public InventoryPlayer inv;//always null I guess
- public ArrayList fwItems = new ArrayList();
- public ContainerBolus(InventoryPlayer inventory, TileEntityBolus teBolus, World p_i1808_2_, int p_i1808_3_, int p_i1808_4_, int p_i1808_5_)
- {
- this.worldObj = p_i1808_2_;
- this.teBolus = teBolus;
- this.posX = p_i1808_3_;
- this.posY = p_i1808_4_;
- this.posZ = p_i1808_5_;
- this.inv = inventory;
- int l = 0;
- int i1 = 0;
- //result
- for (l = 0; l < 3; ++l)
- {
- for (i1 = 0; i1 < 3; ++i1)
- {
- this.addSlotToContainer(new SlotCrafting(inventory.player, this.teBolus, this.craftResult, i1 + l * 2, 117 + i1 * 18, 18 + l * 18));
- }
- }
- //"offerings"
- for (l = 0; l < 3; ++l)
- {
- for (i1 = 0; i1 < 3; ++i1)
- {
- this.addSlotToContainer(new Slot(this.teBolus, i1 + l * 3, 27 + i1 * 18, 18 + l * 18));
- }
- }
- l = 0;
- i1 = 0;
- //inventory sans hotbar
- for (l = 0; l < 3; ++l)
- {
- for (i1 = 0; i1 < 9; ++i1)
- {
- this.addSlotToContainer(new Slot(inventory, i1 + l * 9 + 9, 18 + i1 * 18, 85 + l * 18));
- }
- }
- //hotbar
- for (l = 0; l < 9; ++l)
- {
- this.addSlotToContainer(new Slot(inventory, l, 18 + l * 18, 143)); //x+10, y + 5
- }
- //this.onCraftMatrixChanged(this.craftMatrix);
- }
- public ArrayList updateFWItems(){
- this.fwItems.clear();
- for(int i = 0; i < this.inventorySlots.size(); i++){
- if(getSlot(i).getHasStack()){
- if((getSlot(i).getStack().getItem().getUnlocalizedName()).equals(FleshWorks.itemFWWeaponBase.getUnlocalizedName()) ||
- (getSlot(i).getStack().getItem().getUnlocalizedName()).equals(FleshWorks.itemBootsFW.getUnlocalizedName()) ||
- (getSlot(i).getStack().getItem().getUnlocalizedName()).equals(FleshWorks.itemChestplateFW.getUnlocalizedName()) ||
- (getSlot(i).getStack().getItem().getUnlocalizedName()).equals(FleshWorks.itemLeggingsFW.getUnlocalizedName()) ||
- (getSlot(i).getStack().getItem().getUnlocalizedName()).equals(FleshWorks.itemHelmetFW.getUnlocalizedName()))
- {
- this.fwItems.add(inventorySlots.get(i));
- }
- }
- }
- //System.out.println("\nNumber of FW items: " + fwItems.size() + "\n");
- return this.fwItems;
- }
- public int getNumberOfFWItems(){
- return this.fwItems.size();
- }
- public ArrayList getFWItems(){
- return this.fwItems;
- }
- /**
- * Callback for when the crafting matrix is changed.
- */
- /*@Override
- public void onCraftMatrixChanged(IInventory p_75130_1_)
- {
- this.craftResult.setInventorySlotContents(0, CraftingManagerFW.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
- updateFWItems();
- }*/
- /**
- * Called when the container is closed.
- */
- /*public void onContainerClosed(EntityPlayer p_75134_1_)
- {
- super.onContainerClosed(p_75134_1_);
- if (!this.worldObj.isRemote)
- {
- for (int i = 0; i < 9; ++i)
- {
- ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
- if (itemstack != null)
- {
- p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false);
- }
- }
- }
- }*/
- public boolean canInteractWith(EntityPlayer player)
- {
- return true;
- }
- /**
- * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
- */
- 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_ == 0)
- {
- if (!this.mergeItemStack(itemstack1, 10, 46, true))
- {
- return null;
- }
- slot.onSlotChange(itemstack1, itemstack);
- }
- else if (p_82846_2_ >= 10 && p_82846_2_ < 37)
- {
- if (!this.mergeItemStack(itemstack1, 37, 46, false))
- {
- return null;
- }
- }
- else if (p_82846_2_ >= 37 && p_82846_2_ < 46)
- {
- if (!this.mergeItemStack(itemstack1, 10, 37, false))
- {
- return null;
- }
- }
- else if (!this.mergeItemStack(itemstack1, 10, 46, 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 func_94530_a(ItemStack itemStack, Slot slot)//canInteractWithSlot, maybe?
- {
- return /*slot.inventory != this.craftResult && */super.func_94530_a(itemStack, slot);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement