Guest User

Untitled

a guest
Jul 29th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. package org.freefourms.geforce.securitycraft.blocks;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.block.BlockChest;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.inventory.IInventory;
  7. import net.minecraft.tileentity.TileEntity;
  8. import net.minecraft.world.World;
  9.  
  10. import org.freefourms.geforce.securitycraft.main.mod_SecurityCraft;
  11. import org.freefourms.geforce.securitycraft.tileentity.TileEntityKeypadChest;
  12.  
  13. public class BlockKeypadChest extends BlockChest{
  14.  
  15. public BlockKeypadChest(int par1) {
  16. super(par1);
  17. }
  18.  
  19. /**
  20. * Called upon block activation (right click on the block.)
  21. */
  22. public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
  23. {
  24. if (par1World.isRemote)
  25. {
  26. return true;
  27. }
  28. else
  29. {
  30. IInventory iinventory = this.func_149951_m(par1World, par2, par3, par4);
  31.  
  32. if (iinventory != null)
  33. {
  34. if(par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityKeypadChest){
  35. if(((TileEntityKeypadChest) par1World.getTileEntity(par2, par3, par4)).getKeypadCode() != 0){
  36. par5EntityPlayer.openGui(mod_SecurityCraft.instance, 13, par1World, par2, par3, par4);
  37. }else{
  38. par5EntityPlayer.openGui(mod_SecurityCraft.instance, 12, par1World, par2, par3, par4);
  39.  
  40. }
  41. }
  42.  
  43. }
  44.  
  45. return true;
  46. }
  47. }
  48.  
  49. /**
  50. * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
  51. * their own) Args: x, y, z, neighbor Block
  52. */
  53. public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5Block)
  54. {
  55. super.onNeighborBlockChange(par1World, par2, par3, par4, par5Block);
  56. TileEntityKeypadChest tileentitychest = (TileEntityKeypadChest)par1World.getTileEntity(par2, par3, par4);
  57.  
  58. if (tileentitychest != null)
  59. {
  60. tileentitychest.updateContainingBlockInfo();
  61. }
  62.  
  63. }
  64.  
  65. /**
  66. * Returns a new instance of a block's tile entity class. Called on placing the block.
  67. */
  68. public TileEntity createNewTileEntity(World par1World, int par2)
  69. {
  70. return new TileEntityKeypadChest();
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment