@Override public void onUpdate() { if (!worldObj.isRemote && (getThrowingEntity() == null || getThrowingEntity().isDead)) { setDead(); return; } else { ticksExisted++; if (ticksExisted >= maxTicksToExist && !worldObj.isRemote) { setDead(); return; } } if (getThrowingEntity() != null && getThrowingEntity() instanceof EntityNatureGuardian) { ((EntityNatureGuardian) getThrowingEntity()).hasSickle = false; } Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ); Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1); vec3d = Vec3.createVectorHelper(posX, posY, posZ); vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); if (movingobjectposition != null) { vec3d1 = Vec3.createVectorHelper( movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = worldObj.getEntitiesWithinAABBExcludingEntity( this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); double d = 0.0D; for (int j = 0; j < list.size(); j++) { Entity entity1 = (Entity) list.get(j); if (!entity1.canBeCollidedWith() || entity1.isEntityEqual(getThrowingEntity()) && ticksExisted < 25) { continue; } float f2 = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2); MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1); if (movingobjectposition1 == null) { continue; } double d1 = vec3d.distanceTo(movingobjectposition1.hitVec); if (d1 < d || d == 0.0D) { entity = entity1; d = d1; } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } else { movingobjectposition = new MovingObjectPosition( (int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ), 0, Vec3.createVectorHelper(posX, posY, posZ)); } if (movingobjectposition != null) { HitObject(movingobjectposition); } posX += motionX; posY += motionY; posZ += motionZ; float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D); for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {} for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {} for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {} for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {} rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; float f1 = 0.95F; if (isInWater()) { for (int k = 0; k < 4; k++) { float f3 = 0.25F; worldObj.spawnParticle( "bubble", posX - motionX * f3, posY - motionY * f3, posZ - motionZ * f3, motionX, motionY, motionZ); } f1 = 0.8F; } setPosition(posX, posY, posZ); if (this.ticksExisted > 30 && this.ticksExisted < 40) { this.motionX *= 0.8f; this.motionY *= 0.8f; this.motionZ *= 0.8f; } else if (this.ticksExisted > 40 && getThrowingEntity() != null) { double deltaX = this.posX - getThrowingEntity().posX; double deltaZ = this.posZ - getThrowingEntity().posZ; double deltaY = this.posY - getThrowingEntity().posY; double angle = Math.atan2(deltaZ, deltaX); double speed = Math.min((this.ticksExisted - 40f) / 10f, this.getProjectileSpeed()); double horizontalDistance = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ); float pitchRotation = (float) (-Math.atan2(deltaY, horizontalDistance)); this.motionX = -Math.cos(angle) * speed; this.motionZ = -Math.sin(angle) * speed; this.motionY = Math.sin(pitchRotation) * speed; if (this.getDistanceSqToEntity(getThrowingEntity()) < 1.2 && !worldObj.isRemote) { this.setDead(); } } }
@Override public void onUpdate() { this.setRotation(this.rotationYaw + 2F, this.rotationPitch + 2F); this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.motionY -= 0.03999999910593033D; this.moveEntity(this.motionX, this.motionY, this.motionZ); if (this.worldObj.isRemote) { this.spawnParticles(); } Vec3 var15 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); Vec3 var2 = Vec3.createVectorHelper( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition var3 = this.worldObj.func_147447_a(var15, var2, true, true, false); var15 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); var2 = Vec3.createVectorHelper( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (var3 != null) { var2 = Vec3.createVectorHelper(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord); } Entity var4 = null; List<?> var5 = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.boundingBox .addCoord(this.motionX, this.motionY, this.motionZ) .expand(2.0D, 2.0D, 2.0D)); double var6 = 0.0D; Iterator<?> var8 = var5.iterator(); while (var8.hasNext()) { Entity var9 = (Entity) var8.next(); if (var9.canBeCollidedWith() && !var9.isEntityEqual(this.shootingEntity)) { float var10 = 0.01F; AxisAlignedBB var11 = var9.boundingBox.expand(var10, var10, var10); MovingObjectPosition var12 = var11.calculateIntercept(var15, var2); if (var12 != null) { double var13 = var15.distanceTo(var12.hitVec); if (var13 < var6 || var6 == 0.0D) { var4 = var9; var6 = var13; } } } } if (var4 != null) { var3 = new MovingObjectPosition(var4); } if (var3 != null) { this.onImpact(var3); } if (this.posY <= -20 || this.posY >= 400) { this.setDead(); } }
@Override public void onUpdate() { ticksExisted++; boolean hit = false; int id = worldObj.getBlockId((int) posX, (int) posY, (int) posZ); MachineRegistry m = MachineRegistry.getMachine(worldObj, posX, posY, posZ); List mobs = worldObj.getEntitiesWithinAABB(EntityLiving.class, this.getBoundingBox().expand(1, 1, 1)); // ReikaJavaLibrary.pConsole("ID: "+id+" and "+mobs.size()+" mobs"); hit = (mobs.size() > 0 || (m != MachineRegistry.RAILGUN && id != 0 && !ReikaWorldHelper.softBlocks(id))); // ReikaJavaLibrary.pConsole(hit+" by "+id+" or mobs "+mobs.size()); if (ReikaWorldHelper.softBlocks(id) && !ReikaMathLibrary.isValueInsideBoundsIncl(8, 11, id) && ConfigRegistry.BLOCKDAMAGE.getState()) ReikaWorldHelper.recursiveBreakWithinSphere( worldObj, (int) posX, (int) posY, (int) posZ, id, -1, (int) posX, (int) posY, (int) posZ, 4); if (hit) { // ReikaChatHelper.write("HIT @ "+ticksExisted+" by "+(mobs.size() > 0)); this.onImpact(null); if (power < 15) this.setDead(); return; } // ReikaChatHelper.write(this.ticksExisted); for (float i = -0.2F; i <= 0.2; i += 0.2F) worldObj.createExplosion(this, posX + i, posY + i, posZ + i, 0F, false); // worldObj.spawnParticle("hugeexplosion", posX, posY, posZ, 0, 0, 0); if (!worldObj.isRemote && (shootingEntity != null && shootingEntity.isDead || !worldObj.blockExists((int) posX, (int) posY, (int) posZ))) this.setDead(); else { if (ticksExisted > 80 && !worldObj.isRemote) this.onImpact(null); this.onEntityUpdate(); Vec3 var15 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); Vec3 var2 = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); MovingObjectPosition var3 = worldObj.rayTraceBlocks(var15, var2); var15 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); var2 = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); if (var3 != null) var2 = worldObj .getWorldVec3Pool() .getVecFromPool(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord); Entity var4 = null; List var5 = worldObj.getEntitiesWithinAABBExcludingEntity( this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); double var6 = 0.0D; for (int var8 = 0; var8 < var5.size(); ++var8) { Entity var9 = (Entity) var5.get(var8); if (var9.canBeCollidedWith() && (!var9.isEntityEqual(shootingEntity))) { float var10 = 0.3F; AxisAlignedBB var11 = var9.boundingBox.expand(var10, var10, var10); MovingObjectPosition var12 = var11.calculateIntercept(var15, var2); if (var12 != null) { double var13 = var15.distanceTo(var12.hitVec); if (var13 < var6 || var6 == 0.0D) { var4 = var9; var6 = var13; } } } } if (var4 != null) var3 = new MovingObjectPosition(var4); if (var3 != null) this.onImpact(var3); posX += motionX; posY += motionY; posZ += motionZ; if (this.isInWater()) { worldObj.createExplosion(this, posX, posY, posZ, 3F, false); for (int var19 = 0; var19 < 4; ++var19) { float var18 = 0.25F; worldObj.spawnParticle( "bubble", posX - motionX * var18, posY - motionY * var18, posZ - motionZ * var18, motionX, motionY, motionZ); } } this.setPosition(posX, posY, posZ); } }