1 package pcc.chemicraft.entity;
3 import net.minecraft.entity.Entity;
4 import net.minecraft.entity.projectile.EntityThrowable;
5 import net.minecraft.nbt.NBTTagCompound;
6 import net.minecraft.util.MathHelper;
7 import net.minecraft.util.MovingObjectPosition;
8 import net.minecraft.world.World;
10 public class EntityDust extends Entity {
12 private final float explodeSize = 2.0F;
13 private final short explodeRad = 5;
14 private int delay = 0;
15 private int deadDelay = 20;
16 private float rad = 0;
18 public EntityDust(World par1World) {
22 public EntityDust(World par1World, double par2, double par3, double par4) {
30 public void onUpdate() {
33 if (this.delay > 100) {
34 if (this.deadDelay > 0) {
37 if (this.deadDelay % 4 == 0) {
38 this.explode(this.rad, false);
39 } else if (this.deadDelay % 6 == 0){
40 this.explode(this.rad, true);
47 float var17 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
48 this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
50 for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var17) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
55 while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
57 this.prevRotationPitch += 360.0F;
60 while (this.rotationYaw - this.prevRotationYaw < -180.0F)
62 this.prevRotationYaw -= 360.0F;
65 while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
67 this.prevRotationYaw += 360.0F;
70 this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
71 this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
76 protected void entityInit() {
81 public void readEntityFromNBT(NBTTagCompound var1) {
86 public void writeEntityToNBT(NBTTagCompound var1) {
90 private void explode(double r, boolean b) {
93 for (int i = 0; i < r; i++) {
94 double y = this.posY - (r/2) + (i * 1F);
96 for (int j = 1; j < r; j++) {
97 ry = Math.sin((double) i / r * Math.PI) * 8;
99 double x = this.posX - Math.sin(Math.toRadians(angle)) * ry;
100 double z = this.posZ + Math.cos(Math.toRadians(angle)) * ry;
101 if (!this.worldObj.isRemote){
102 this.worldObj.createExplosion(this, x - 6 + Math.random() * 12, y + 3, z - 6 + Math.random() * 12, this.explodeSize, b);
108 public int getDelay() {