package net.minecraft.entity.item; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.WorldProviderEnd; public class EntityEnderCrystal extends Entity { /** Used to create the rotation animation when rendering the crystal. */ public int innerRotation; public int health; private static final String __OBFID = "CL_00001658"; public EntityEnderCrystal(World worldIn) { super(worldIn); this.preventEntitySpawning = true; this.setSize(2.0F, 2.0F); this.health = 5; this.innerRotation = this.rand.nextInt(100000); } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } protected void entityInit() { this.dataWatcher.addObject(8, Integer.valueOf(this.health)); } /** * Called to update the entity's position/logic. */ public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; ++this.innerRotation; this.dataWatcher.updateObject(8, Integer.valueOf(this.health)); int var1 = MathHelper.floor_double(this.posX); int var2 = MathHelper.floor_double(this.posY); int var3 = MathHelper.floor_double(this.posZ); if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlockState(new BlockPos(var1, var2, var3)).getBlock() != Blocks.fire) { this.worldObj.setBlockState(new BlockPos(var1, var2, var3), Blocks.fire.getDefaultState()); } } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ protected void writeEntityToNBT(NBTTagCompound tagCompound) {} /** * (abstract) Protected helper method to read subclass entity data from NBT. */ protected void readEntityFromNBT(NBTTagCompound tagCompund) {} /** * Returns true if other Entities should be prevented from moving through this Entity. */ public boolean canBeCollidedWith() { return true; } /** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.func_180431_b(source)) { return false; } else { if (!this.isDead && !this.worldObj.isRemote) { this.health = 0; if (this.health <= 0) { this.setDead(); if (!this.worldObj.isRemote) { this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 6.0F, true); } } } return true; } } }