mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
125 lines
3.4 KiB
Java
125 lines
3.4 KiB
Java
package com.hbm.entity.logic;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.util.DamageSource;
|
|
import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.WorldProviderEnd;
|
|
|
|
public class EntityMissileTest 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 EntityMissileTest(World p_i1698_1_)
|
|
{
|
|
super(p_i1698_1_);
|
|
this.preventEntitySpawning = true;
|
|
this.setSize(2.0F, 2.0F);
|
|
this.yOffset = this.height / 2.0F;
|
|
this.health = 5;
|
|
this.innerRotation = this.rand.nextInt(100000);
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public EntityMissileTest(World p_i1699_1_, double p_i1699_2_, double p_i1699_4_, double p_i1699_6_)
|
|
{
|
|
this(p_i1699_1_);
|
|
this.setPosition(p_i1699_2_, p_i1699_4_, p_i1699_6_);
|
|
}
|
|
|
|
/**
|
|
* 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 i = MathHelper.floor_double(this.posX);
|
|
int j = MathHelper.floor_double(this.posY);
|
|
int k = MathHelper.floor_double(this.posZ);
|
|
|
|
if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlock(i, j, k) != Blocks.fire)
|
|
{
|
|
this.worldObj.setBlock(i, j, k, Blocks.fire);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* (abstract) Protected helper method to write subclass entity data to NBT.
|
|
*/
|
|
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {}
|
|
|
|
/**
|
|
* (abstract) Protected helper method to read subclass entity data from NBT.
|
|
*/
|
|
protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public float getShadowSize()
|
|
{
|
|
return 0.0F;
|
|
}
|
|
|
|
/**
|
|
* 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 p_70097_1_, float p_70097_2_)
|
|
{
|
|
if (this.isEntityInvulnerable())
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|