Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //ITEM CODE:
- public class enderPack extends Item
- {
- public static List<backpackTile> backpackList = new ArrayList<backpackTile>();
- //private backpackTile enderPackData = new backpackTile();//Using only one, any player could access the tileData
- @Override//Clears the item coords
- public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn)
- {
- //if(backpackList.)
- if(playerIn.isSneaking())
- {
- //This next part should loop until it finds a players data.
- if(backpackList.isEmpty())
- {
- backpackList.add(new backpackTile(playerIn));
- //backpackList.get(backpackList.size()-1).setChestID(playerIn.playerLocation.getX());//setChestID here
- System.out.println("\nNo backpacks existed, adding first.");
- }
- for (int i = backpackList.size()-1; i >= 0; i--)
- {
- if(backpackList.get(i) != null)
- {
- if (backpackList.get(i).getPlayerData().getName().equals(playerIn.getName()))
- {
- backpackTile enderPackInventory = backpackList.get(i);
- BlockPos pos = new BlockPos(1,1,1);
- TileEntity tileentity = worldIn.getTileEntity(pos );
- enderPackInventory.setChestTileEntity((TileEntityEnderChest)tileentity);
- playerIn.displayGUIChest(enderPackInventory);
- System.out.println("\nFound entry with EXACT match to player: " + playerIn.getName() + " VS: "+ backpackList.get(i).getPlayerData().getName());
- }
- else
- {
- System.out.println("\nFound entry with no match to player: " + playerIn.getName() + " VS: "+ backpackList.get(i).getPlayerData().getName());
- }
- }
- }
- }
- return stack;
- }
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //EnderPouchTileData
- public class enderPouchTile extends InventoryBasic
- {
- private TileEntityEnderChest associatedChest;
- private static final String __OBFID = "CL_00001759";
- private EntityPlayer playerData;
- public enderPouchTile(EntityPlayer playerIn)
- {
- super("Ender Pack", false, 27);
- Random rand = new Random();
- playerData = playerIn;
- System.out.println("\nPlayerIN: " + playerData.getName());
- }
- public void setChestTileEntity(TileEntityEnderChest chestTileEntity)
- {
- this.associatedChest = chestTileEntity;
- }
- public void loadInventoryFromNBT(NBTTagList tagList)
- {
- int i;
- for (i = 0; i < this.getSizeInventory(); ++i)
- {
- this.setInventorySlotContents(i, (ItemStack)null);
- }
- for (i = 0; i < tagList.tagCount(); ++i)
- {
- NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
- int j = nbttagcompound.getByte("Slot") & 255;
- if (j >= 0 && j < this.getSizeInventory())
- {
- this.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound));
- }
- }
- }
- public NBTTagList saveInventoryToNBT()
- {
- NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < this.getSizeInventory(); ++i)
- {
- ItemStack itemstack = this.getStackInSlot(i);
- if (itemstack != null)
- {
- NBTTagCompound nbttagcompound = new NBTTagCompound();
- nbttagcompound.setByte("Slot", (byte)i);
- itemstack.writeToNBT(nbttagcompound);
- nbttaglist.appendTag(nbttagcompound);
- }
- }
- return nbttaglist;
- }
- /**
- * Do not make give this method the name canInteractWith because it clashes with Container
- */
- public boolean isUseableByPlayer(EntityPlayer player)
- {
- return this.associatedChest != null && !this.associatedChest.func_145971_a(player) ? false : super.isUseableByPlayer(player);
- }
- public void openInventory(EntityPlayer player)
- {
- if (this.associatedChest != null)
- {
- this.associatedChest.func_145969_a();
- }
- super.openInventory(player);
- }
- public void closeInventory(EntityPlayer player)
- {
- if (this.associatedChest != null)
- {
- this.associatedChest.func_145970_b();
- }
- super.closeInventory(player);
- this.associatedChest = null;
- }
- public EntityPlayer getPlayerData()
- {
- return playerData;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement