SHOW:
|
|
- or go back to the newest paste.
| 1 | package net.minecraft.src; | |
| 2 | ||
| 3 | import java.util.List; | |
| 4 | import java.util.Random; | |
| 5 | ||
| 6 | - | public class EntityFireball extends Entity |
| 6 | + | public class EntityTPHFlamethrower extends EntityFireball |
| 7 | {
| |
| 8 | private int xTile; | |
| 9 | private int yTile; | |
| 10 | private int zTile; | |
| 11 | private int inTile; | |
| 12 | private boolean inGround; | |
| 13 | - | public EntityLiving shootingEntity; |
| 13 | + | |
| 14 | private int ticksInAir; | |
| 15 | public float moveSpeed; | |
| 16 | - | public double accelerationX; |
| 16 | + | public double destX; |
| 17 | - | public double accelerationY; |
| 17 | + | public double destZ; |
| 18 | - | public double accelerationZ; |
| 18 | + | |
| 19 | public EntityTPHFlamethrower(World par1World, EntityLiving shooter, EntityLiving target) | |
| 20 | - | public EntityFireball(World par1World) |
| 20 | + | |
| 21 | super(par1World); | |
| 22 | xTile = -1; | |
| 23 | yTile = -1; | |
| 24 | zTile = -1; | |
| 25 | inTile = 0; | |
| 26 | inGround = false; | |
| 27 | ticksInAir = 0; | |
| 28 | destX = target.posX; | |
| 29 | destZ = target.posZ; | |
| 30 | moveSpeed = 1.0F; | |
| 31 | shootingEntity = shooter; | |
| 32 | setSize(1.0F, 1.0F); | |
| 33 | } | |
| 34 | ||
| 35 | protected void entityInit() | |
| 36 | {
| |
| 37 | } | |
| 38 | ||
| 39 | /** | |
| 40 | * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge | |
| 41 | * length * 64 * renderDistanceWeight Args: distance | |
| 42 | */ | |
| 43 | public boolean isInRangeToRenderDist(double par1) | |
| 44 | {
| |
| 45 | double d = boundingBox.getAverageEdgeLength() * 4D; | |
| 46 | d *= 64D; | |
| 47 | - | public EntityFireball(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) |
| 47 | + | |
| 48 | } | |
| 49 | ||
| 50 | /** | |
| 51 | * Called to update the entity's position/logic. | |
| 52 | */ | |
| 53 | public void onUpdate() | |
| 54 | {
| |
| 55 | if (something((int)posX, (int)posY, (int)posZ)) | |
| 56 | {
| |
| 57 | - | setLocationAndAngles(par2, par4, par6, rotationYaw, rotationPitch); |
| 57 | + | if (something((int)posX, (int)posY + 1, (int)posZ)) |
| 58 | - | setPosition(par2, par4, par6); |
| 58 | + | {
|
| 59 | - | double d = MathHelper.sqrt_double(par8 * par8 + par10 * par10 + par12 * par12); |
| 59 | + | setDead(); |
| 60 | - | accelerationX = (par8 / d) * 0.10000000000000001D; |
| 60 | + | return; |
| 61 | - | accelerationY = (par10 / d) * 0.10000000000000001D; |
| 61 | + | } else posY += 1; |
| 62 | - | accelerationZ = (par12 / d) * 0.10000000000000001D; |
| 62 | + | } else if (!something((int)posX, (int)posY - 1, (int)posZ)) {
|
| 63 | if (!something((int)posX, (int)posY - 2, (int)posZ)){
| |
| 64 | setDead(); | |
| 65 | - | public EntityFireball(World par1World, EntityLiving par2EntityLiving, double par3, double par5, double par7) |
| 65 | + | return; |
| 66 | } else posY -= 1; | |
| 67 | } | |
| 68 | ||
| 69 | worldObj.setBlockWithNotify((int) posX, (int) posY, (int) posZ, Block.fire.blockID); | |
| 70 | super.onUpdate(); | |
| 71 | setFire(1); | |
| 72 | ||
| 73 | //if (inGround) | |
| 74 | - | shootingEntity = par2EntityLiving; |
| 74 | + | //{
|
| 75 | //int i = worldObj.getBlockId(xTile, yTile, zTile); | |
| 76 | - | setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY, par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch); |
| 76 | + | |
| 77 | //if (i != inTile) | |
| 78 | - | yOffset = 0.0F; |
| 78 | + | //{
|
| 79 | - | motionX = motionY = motionZ = 0.0D; |
| 79 | + | // inGround = false; |
| 80 | - | par3 += rand.nextGaussian() * 0.40000000000000002D; |
| 80 | + | // motionX *= rand.nextFloat() * 0.2F; |
| 81 | - | par5 += rand.nextGaussian() * 0.40000000000000002D; |
| 81 | + | // motionY *= rand.nextFloat() * 0.2F; |
| 82 | - | par7 += rand.nextGaussian() * 0.40000000000000002D; |
| 82 | + | // motionZ *= rand.nextFloat() * 0.2F; |
| 83 | - | double d = MathHelper.sqrt_double(par3 * par3 + par5 * par5 + par7 * par7); |
| 83 | + | // ticksAlive = 0; |
| 84 | - | accelerationX = (par3 / d) * 0.10000000000000001D; |
| 84 | + | // ticksInAir = 0; |
| 85 | - | accelerationY = (par5 / d) * 0.10000000000000001D; |
| 85 | + | //} |
| 86 | - | accelerationZ = (par7 / d) * 0.10000000000000001D; |
| 86 | + | //else |
| 87 | //{
| |
| 88 | ticksAlive++; | |
| 89 | ||
| 90 | if (ticksAlive >= 100) | |
| 91 | {
| |
| 92 | setDead(); | |
| 93 | worldObj.newExplosion(null, posX, posY, posZ, 1.0F, true); | |
| 94 | - | if (!worldObj.isRemote && (shootingEntity != null && shootingEntity.isDead || !worldObj.blockExists((int)posX, (int)posY, (int)posZ))) |
| 94 | + | |
| 95 | ||
| 96 | //return; | |
| 97 | - | return; |
| 97 | + | //} |
| 98 | //} | |
| 99 | //else | |
| 100 | //{
| |
| 101 | ticksInAir++; | |
| 102 | //} | |
| 103 | - | if (inGround) |
| 103 | + | |
| 104 | Vec3D vec3d = Vec3D.createVector(posX, posY, posZ); | |
| 105 | - | int i = worldObj.getBlockId(xTile, yTile, zTile); |
| 105 | + | |
| 106 | MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1); | |
| 107 | - | if (i != inTile) |
| 107 | + | |
| 108 | vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ); | |
| 109 | - | inGround = false; |
| 109 | + | |
| 110 | - | motionX *= rand.nextFloat() * 0.2F; |
| 110 | + | |
| 111 | - | motionY *= rand.nextFloat() * 0.2F; |
| 111 | + | |
| 112 | - | motionZ *= rand.nextFloat() * 0.2F; |
| 112 | + | |
| 113 | - | ticksAlive = 0; |
| 113 | + | |
| 114 | - | ticksInAir = 0; |
| 114 | + | |
| 115 | Entity entity = null; | |
| 116 | - | else |
| 116 | + | |
| 117 | double d = 0.0D; | |
| 118 | ||
| 119 | for (int j = 0; j < list.size(); j++) | |
| 120 | - | if (ticksAlive == 600) |
| 120 | + | |
| 121 | Entity entity1 = (Entity)list.get(j); | |
| 122 | ||
| 123 | if (!entity1.canBeCollidedWith() || entity1.isEntityEqual(shootingEntity) && ticksInAir < 25) | |
| 124 | {
| |
| 125 | - | return; |
| 125 | + | |
| 126 | } | |
| 127 | ||
| 128 | - | else |
| 128 | + | |
| 129 | AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2); | |
| 130 | MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1); | |
| 131 | ||
| 132 | if (movingobjectposition1 == null) | |
| 133 | {
| |
| 134 | continue; | |
| 135 | } | |
| 136 | ||
| 137 | double d1 = vec3d.distanceTo(movingobjectposition1.hitVec); | |
| 138 | ||
| 139 | if (d1 < d || d == 0.0D) | |
| 140 | {
| |
| 141 | entity = entity1; | |
| 142 | d = d1; | |
| 143 | } | |
| 144 | } | |
| 145 | ||
| 146 | if (entity != null) | |
| 147 | {
| |
| 148 | movingobjectposition = new MovingObjectPosition(entity); | |
| 149 | } | |
| 150 | ||
| 151 | if (movingobjectposition != null) | |
| 152 | {
| |
| 153 | func_40071_a(movingobjectposition); | |
| 154 | } | |
| 155 | ||
| 156 | posX += motionX; | |
| 157 | posY += motionY; | |
| 158 | posZ += motionZ; | |
| 159 | float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); | |
| 160 | //rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / Math.PI); | |
| 161 | ||
| 162 | //for (rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / Math.PI); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) { }
| |
| 163 | ||
| 164 | //for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) { }
| |
| 165 | ||
| 166 | //for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) { }
| |
| 167 | ||
| 168 | //for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) { }
| |
| 169 | ||
| 170 | //rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; | |
| 171 | //rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; | |
| 172 | float f1 = 0.95F; | |
| 173 | ||
| 174 | if (isInWater()) | |
| 175 | {
| |
| 176 | for (int k = 0; k < 4; k++) | |
| 177 | {
| |
| 178 | float f3 = 0.25F; | |
| 179 | worldObj.spawnParticle("bubble", posX - motionX * (double)f3, posY - motionY * (double)f3, posZ - motionZ * (double)f3, motionX, motionY, motionZ);
| |
| 180 | } | |
| 181 | ||
| 182 | f1 = 0.8F; | |
| 183 | } | |
| 184 | ||
| 185 | //motionX += accelerationX; | |
| 186 | //motionY += accelerationY; | |
| 187 | //motionZ += accelerationZ; | |
| 188 | //motionX *= f1; | |
| 189 | - | rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / Math.PI); |
| 189 | + | //motionY *= f1; |
| 190 | //motionZ *= f1; | |
| 191 | - | for (rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / Math.PI); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) { }
|
| 191 | + | |
| 192 | motionX = Math.cos(Math.toRadians(rotationYaw)) * moveSpeed; | |
| 193 | - | for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) { }
|
| 193 | + | motionY = 0; |
| 194 | motionZ = Math.sin(Math.toRadians(rotationYaw)) * moveSpeed; | |
| 195 | - | for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) { }
|
| 195 | + | float n = (float) Math.atan2(destZ - 100, destX - 100) - rotationYaw; |
| 196 | rotationYaw += (n > ticksAlive) ? (float) ticksAlive : n; | |
| 197 | - | for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) { }
|
| 197 | + | //worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
|
| 198 | setPosition(posX, posY, posZ); | |
| 199 | - | rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; |
| 199 | + | |
| 200 | - | rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; |
| 200 | + | |
| 201 | protected void func_40071_a(MovingObjectPosition par1MovingObjectPosition) | |
| 202 | {
| |
| 203 | if (!worldObj.isRemote) | |
| 204 | {
| |
| 205 | if (par1MovingObjectPosition.entityHit != null) | |
| 206 | {
| |
| 207 | if (!par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeFireballDamage((EntityFireball) this, shootingEntity), 4)); | |
| 208 | } | |
| 209 | ||
| 210 | worldObj.newExplosion(null, posX, posY, posZ, 1.0F, true); | |
| 211 | setDead(); | |
| 212 | } | |
| 213 | } | |
| 214 | - | motionX += accelerationX; |
| 214 | + | |
| 215 | - | motionY += accelerationY; |
| 215 | + | |
| 216 | - | motionZ += accelerationZ; |
| 216 | + | |
| 217 | - | motionX *= f1; |
| 217 | + | |
| 218 | - | motionY *= f1; |
| 218 | + | |
| 219 | - | motionZ *= f1; |
| 219 | + | |
| 220 | - | worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
|
| 220 | + | |
| 221 | par1NBTTagCompound.setShort("yTile", (short)yTile);
| |
| 222 | par1NBTTagCompound.setShort("zTile", (short)zTile);
| |
| 223 | par1NBTTagCompound.setByte("inTile", (byte)inTile);
| |
| 224 | par1NBTTagCompound.setByte("inGround", (byte)(inGround ? 1 : 0));
| |
| 225 | } | |
| 226 | ||
| 227 | /** | |
| 228 | * (abstract) Protected helper method to read subclass entity data from NBT. | |
| 229 | */ | |
| 230 | - | if (!par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, shootingEntity), 4)); |
| 230 | + | |
| 231 | {
| |
| 232 | xTile = par1NBTTagCompound.getShort("xTile");
| |
| 233 | yTile = par1NBTTagCompound.getShort("yTile");
| |
| 234 | zTile = par1NBTTagCompound.getShort("zTile");
| |
| 235 | inTile = par1NBTTagCompound.getByte("inTile") & 0xff;
| |
| 236 | inGround = par1NBTTagCompound.getByte("inGround") == 1;
| |
| 237 | } | |
| 238 | ||
| 239 | /** | |
| 240 | * Returns true if other Entities should be prevented from moving through this Entity. | |
| 241 | */ | |
| 242 | public boolean canBeCollidedWith() | |
| 243 | {
| |
| 244 | return true; | |
| 245 | } | |
| 246 | ||
| 247 | public float getCollisionBorderSize() | |
| 248 | {
| |
| 249 | return 1.0F; | |
| 250 | } | |
| 251 | ||
| 252 | public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) | |
| 253 | {
| |
| 254 | setBeenAttacked(); | |
| 255 | if (par1DamageSource.getEntity() != null) | |
| 256 | return true; | |
| 257 | else | |
| 258 | return false; | |
| 259 | } | |
| 260 | ||
| 261 | public float getShadowSize() | |
| 262 | {
| |
| 263 | return 0.0F; | |
| 264 | } | |
| 265 | ||
| 266 | /** | |
| 267 | * Gets how bright this entity is. | |
| 268 | */ | |
| 269 | public float getBrightness(float par1) | |
| 270 | {
| |
| 271 | return 1.0F; | |
| 272 | } | |
| 273 | ||
| 274 | public int getBrightnessForRender(float par1) | |
| 275 | {
| |
| 276 | - | * Called when the entity is attacked. |
| 276 | + | |
| 277 | } | |
| 278 | ||
| 279 | /** | |
| 280 | - | setBeenAttacked(); |
| 280 | + | * @param Radius |
| 281 | * @param OriginX | |
| 282 | - | if (par1DamageSource.getEntity() != null) |
| 282 | + | * @param OriginY |
| 283 | * @param Angle | |
| 284 | - | Vec3D vec3d = par1DamageSource.getEntity().getLookVec(); |
| 284 | + | * @return Point on circumference of circle at that angle |
| 285 | */ | |
| 286 | - | if (vec3d != null) |
| 286 | + | public double[] GetCircumferencePoints(double Radius, double OriginX, double OriginY, double Angle) |
| 287 | {
| |
| 288 | - | motionX = vec3d.xCoord; |
| 288 | + | double X = OriginX+Radius*Math.sin(Angle*Math.PI/180); |
| 289 | - | motionY = vec3d.yCoord; |
| 289 | + | double Y = OriginY+Radius*-Math.cos(Angle*Math.PI/180); |
| 290 | - | motionZ = vec3d.zCoord; |
| 290 | + | return new double[] {X, Y};
|
| 291 | - | accelerationX = motionX * 0.10000000000000001D; |
| 291 | + | |
| 292 | - | accelerationY = motionY * 0.10000000000000001D; |
| 292 | + | |
| 293 | - | accelerationZ = motionZ * 0.10000000000000001D; |
| 293 | + | public boolean something(int x, int y, int z) |
| 294 | {
| |
| 295 | return (worldObj.blockExists(x, y, z) && worldObj.getBlockId(x, y, z) != Block.fire.blockID); | |
| 296 | - | if (par1DamageSource.getEntity() instanceof EntityLiving) |
| 296 | + | |
| 297 | } |