001 package net.minecraft.src;
002
003 import cpw.mods.fml.common.Side;
004 import cpw.mods.fml.common.asm.SideOnly;
005 import java.util.Random;
006
007 public class BlockEnderChest extends BlockContainer
008 {
009 protected BlockEnderChest(int par1)
010 {
011 super(par1, Material.rock);
012 this.blockIndexInTexture = 37;
013 this.setCreativeTab(CreativeTabs.tabDecorations);
014 this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
015 }
016
017 /**
018 * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
019 * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
020 */
021 public boolean isOpaqueCube()
022 {
023 return false;
024 }
025
026 /**
027 * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
028 */
029 public boolean renderAsNormalBlock()
030 {
031 return false;
032 }
033
034 /**
035 * The type of render function that is called for this block
036 */
037 public int getRenderType()
038 {
039 return 22;
040 }
041
042 /**
043 * Returns the ID of the items to drop on destruction.
044 */
045 public int idDropped(int par1, Random par2Random, int par3)
046 {
047 return Block.obsidian.blockID;
048 }
049
050 /**
051 * Returns the quantity of items to drop on block destruction.
052 */
053 public int quantityDropped(Random par1Random)
054 {
055 return 8;
056 }
057
058 /**
059 * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
060 */
061 protected boolean canSilkHarvest()
062 {
063 return true;
064 }
065
066 /**
067 * Called when the block is placed in the world.
068 */
069 public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
070 {
071 byte var6 = 0;
072 int var7 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
073
074 if (var7 == 0)
075 {
076 var6 = 2;
077 }
078
079 if (var7 == 1)
080 {
081 var6 = 5;
082 }
083
084 if (var7 == 2)
085 {
086 var6 = 3;
087 }
088
089 if (var7 == 3)
090 {
091 var6 = 4;
092 }
093
094 par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
095 }
096
097 /**
098 * Called upon block activation (right click on the block.)
099 */
100 public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
101 {
102 InventoryEnderChest var10 = par5EntityPlayer.getInventoryEnderChest();
103 TileEntityEnderChest var11 = (TileEntityEnderChest)par1World.getBlockTileEntity(par2, par3, par4);
104
105 if (var10 != null && var11 != null)
106 {
107 if (par1World.isBlockNormalCube(par2, par3 + 1, par4))
108 {
109 return true;
110 }
111 else if (par1World.isRemote)
112 {
113 return true;
114 }
115 else
116 {
117 var10.setAssociatedChest(var11);
118 par5EntityPlayer.displayGUIChest(var10);
119 return true;
120 }
121 }
122 else
123 {
124 return true;
125 }
126 }
127
128 /**
129 * Returns a new instance of a block's tile entity class. Called on placing the block.
130 */
131 public TileEntity createNewTileEntity(World par1World)
132 {
133 return new TileEntityEnderChest();
134 }
135
136 @SideOnly(Side.CLIENT)
137
138 /**
139 * A randomly called display update to be able to add particles or other items for display
140 */
141 public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
142 {
143 for (int var6 = 0; var6 < 3; ++var6)
144 {
145 double var10000 = (double)((float)par2 + par5Random.nextFloat());
146 double var9 = (double)((float)par3 + par5Random.nextFloat());
147 var10000 = (double)((float)par4 + par5Random.nextFloat());
148 double var13 = 0.0D;
149 double var15 = 0.0D;
150 double var17 = 0.0D;
151 int var19 = par5Random.nextInt(2) * 2 - 1;
152 int var20 = par5Random.nextInt(2) * 2 - 1;
153 var13 = ((double)par5Random.nextFloat() - 0.5D) * 0.125D;
154 var15 = ((double)par5Random.nextFloat() - 0.5D) * 0.125D;
155 var17 = ((double)par5Random.nextFloat() - 0.5D) * 0.125D;
156 double var11 = (double)par4 + 0.5D + 0.25D * (double)var20;
157 var17 = (double)(par5Random.nextFloat() * 1.0F * (float)var20);
158 double var7 = (double)par2 + 0.5D + 0.25D * (double)var19;
159 var13 = (double)(par5Random.nextFloat() * 1.0F * (float)var19);
160 par1World.spawnParticle("portal", var7, var9, var11, var13, var15, var17);
161 }
162 }
163 }