001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 006 public class EntityEnderCrystal extends Entity 007 { 008 /** Used to create the rotation animation when rendering the crystal. */ 009 public int innerRotation; 010 public int health; 011 012 public EntityEnderCrystal(World par1World) 013 { 014 super(par1World); 015 this.innerRotation = 0; 016 this.preventEntitySpawning = true; 017 this.setSize(2.0F, 2.0F); 018 this.yOffset = this.height / 2.0F; 019 this.health = 5; 020 this.innerRotation = this.rand.nextInt(100000); 021 } 022 023 @SideOnly(Side.CLIENT) 024 public EntityEnderCrystal(World par1World, double par2, double par4, double par6) 025 { 026 this(par1World); 027 this.setPosition(par2, par4, par6); 028 } 029 030 /** 031 * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to 032 * prevent them from trampling crops 033 */ 034 protected boolean canTriggerWalking() 035 { 036 return false; 037 } 038 039 protected void entityInit() 040 { 041 this.dataWatcher.addObject(8, Integer.valueOf(this.health)); 042 } 043 044 /** 045 * Called to update the entity's position/logic. 046 */ 047 public void onUpdate() 048 { 049 this.prevPosX = this.posX; 050 this.prevPosY = this.posY; 051 this.prevPosZ = this.posZ; 052 ++this.innerRotation; 053 this.dataWatcher.updateObject(8, Integer.valueOf(this.health)); 054 int var1 = MathHelper.floor_double(this.posX); 055 int var2 = MathHelper.floor_double(this.posY); 056 int var3 = MathHelper.floor_double(this.posZ); 057 058 if (this.worldObj.getBlockId(var1, var2, var3) != Block.fire.blockID) 059 { 060 this.worldObj.setBlockWithNotify(var1, var2, var3, Block.fire.blockID); 061 } 062 } 063 064 /** 065 * (abstract) Protected helper method to write subclass entity data to NBT. 066 */ 067 protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} 068 069 /** 070 * (abstract) Protected helper method to read subclass entity data from NBT. 071 */ 072 protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} 073 074 @SideOnly(Side.CLIENT) 075 public float getShadowSize() 076 { 077 return 0.0F; 078 } 079 080 /** 081 * Returns true if other Entities should be prevented from moving through this Entity. 082 */ 083 public boolean canBeCollidedWith() 084 { 085 return true; 086 } 087 088 /** 089 * Called when the entity is attacked. 090 */ 091 public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) 092 { 093 if (!this.isDead && !this.worldObj.isRemote) 094 { 095 this.health = 0; 096 097 if (this.health <= 0) 098 { 099 this.setDead(); 100 101 if (!this.worldObj.isRemote) 102 { 103 this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 6.0F); 104 } 105 } 106 } 107 108 return true; 109 } 110 }