diff options
Diffstat (limited to 'src/main/java/gregtech/common/entities/GT_Entity_Arrow.java')
-rw-r--r-- | src/main/java/gregtech/common/entities/GT_Entity_Arrow.java | 219 |
1 files changed, 99 insertions, 120 deletions
diff --git a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java index c07e316684..c5ca19fdad 100644 --- a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java +++ b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java @@ -77,7 +77,7 @@ public class GT_Entity_Arrow extends EntityArrow { if ((this.prevRotationPitch == 0.0F) && (this.prevRotationYaw == 0.0F)) { float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.prevRotationYaw = (this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D - / Math.PI)); + / Math.PI)); this.prevRotationPitch = (this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI)); } if (this.mTicksAlive++ == 3000) { @@ -86,13 +86,10 @@ public class GT_Entity_Arrow extends EntityArrow { Block tBlock = this.worldObj.getBlock(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); if (tBlock.getMaterial() != Material.air) { tBlock.setBlockBoundsBasedOnState(this.worldObj, this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); - AxisAlignedBB axisalignedbb = tBlock.getCollisionBoundingBoxFromPool( - this.worldObj, - this.mHitBlockX, - this.mHitBlockY, - this.mHitBlockZ); + AxisAlignedBB axisalignedbb = tBlock + .getCollisionBoundingBoxFromPool(this.worldObj, this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); if ((axisalignedbb != null) - && (axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))) { + && (axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))) { this.inGround = true; } } @@ -112,24 +109,20 @@ public class GT_Entity_Arrow extends EntityArrow { } else { this.ticksInAir += 1; Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec3 = Vec3.createVectorHelper( - this.posX + this.motionX, - this.posY + this.motionY, - this.posZ + this.motionZ); + Vec3 vec3 = Vec3 + .createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition tVector = this.worldObj.func_147447_a(vec31, vec3, false, true, false); vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - vec3 = Vec3.createVectorHelper( - this.posX + this.motionX, - this.posY + this.motionY, - this.posZ + this.motionZ); + vec3 = Vec3 + .createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (tVector != null) { vec3 = Vec3.createVectorHelper(tVector.hitVec.xCoord, tVector.hitVec.yCoord, tVector.hitVec.zCoord); } Entity tHitEntity = null; List<Entity> tAllPotentiallyHitEntities = this.worldObj.getEntitiesWithinAABBExcludingEntity( - this, - this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ) - .expand(1.0D, 1.0D, 1.0D)); + this, + this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ) + .expand(1.0D, 1.0D, 1.0D)); double tLargestDistance = Double.MAX_VALUE; for (Entity tAllPotentiallyHitEntity : tAllPotentiallyHitEntities) { Entity entity1 = tAllPotentiallyHitEntity; @@ -150,7 +143,7 @@ public class GT_Entity_Arrow extends EntityArrow { } if ((tVector != null) && ((tVector.entityHit instanceof EntityPlayer entityplayer))) { if ((entityplayer.capabilities.disableDamage) || (((tShootingEntity instanceof EntityPlayer)) - && (!((EntityPlayer) tShootingEntity).canAttackPlayer(entityplayer)))) { + && (!((EntityPlayer) tShootingEntity).canAttackPlayer(entityplayer)))) { tVector = null; } } @@ -159,36 +152,34 @@ public class GT_Entity_Arrow extends EntityArrow { ItemData tData = GT_OreDictUnificator.getItemData(this.mArrow); float tMagicDamage = (tVector.entityHit instanceof EntityLivingBase) - ? EnchantmentHelper.func_152377_a( - this.mArrow, - ((EntityLivingBase) tVector.entityHit).getCreatureAttribute()) - : 0.0F; + ? EnchantmentHelper + .func_152377_a(this.mArrow, ((EntityLivingBase) tVector.entityHit).getCreatureAttribute()) + : 0.0F; float tDamage = MathHelper.ceiling_double_int( - MathHelper.sqrt_double( - this.motionX * this.motionX + this.motionY * this.motionY - + this.motionZ * this.motionZ) - * (getDamage() + ((tData != null) && (tData.mMaterial != null) - && (tData.mMaterial.mMaterial != null) - ? tData.mMaterial.mMaterial.mToolQuality / 2.0F - 1.0F - : 0.0F))); + MathHelper.sqrt_double( + this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ) + * (getDamage() + + ((tData != null) && (tData.mMaterial != null) && (tData.mMaterial.mMaterial != null) + ? tData.mMaterial.mMaterial.mToolQuality / 2.0F - 1.0F + : 0.0F))); if (getIsCritical()) { tDamage += this.rand.nextInt((int) (tDamage / 2.0D + 2.0D)); } int tFireDamage = (isBurning() ? 5 : 0) - + 4 * EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow); + + 4 * EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow); int tKnockback = this.mKnockback - + EnchantmentHelper.getEnchantmentLevel(Enchantment.knockback.effectId, this.mArrow); + + EnchantmentHelper.getEnchantmentLevel(Enchantment.knockback.effectId, this.mArrow); int tHitTimer = -1; int[] tDamages = onHitEntity( - tVector.entityHit, - tShootingEntity == null ? this : tShootingEntity, - this.mArrow == null ? new ItemStack(Items.arrow, 1) : this.mArrow, - (int) (tDamage * 2.0F), - (int) (tMagicDamage * 2.0F), - tKnockback, - tFireDamage, - tHitTimer); + tVector.entityHit, + tShootingEntity == null ? this : tShootingEntity, + this.mArrow == null ? new ItemStack(Items.arrow, 1) : this.mArrow, + (int) (tDamage * 2.0F), + (int) (tMagicDamage * 2.0F), + tKnockback, + tFireDamage, + tHitTimer); if (tDamages != null) { tDamage = tDamages[0] / 2.0F; tMagicDamage = tDamages[1] / 2.0F; @@ -199,17 +190,16 @@ public class GT_Entity_Arrow extends EntityArrow { tVector.entityHit.setFire(tFireDamage); } if ((!(tHitEntity instanceof EntityPlayer)) - && (EnchantmentHelper.getEnchantmentLevel(Enchantment.looting.effectId, this.mArrow) - > 0)) { + && (EnchantmentHelper.getEnchantmentLevel(Enchantment.looting.effectId, this.mArrow) > 0)) { EntityPlayer tPlayer = null; if ((this.worldObj instanceof WorldServer)) { tPlayer = FakePlayerFactory.get( - (WorldServer) this.worldObj, - new GameProfile( - new UUID(0L, 0L), - (tShootingEntity instanceof EntityLivingBase) - ? tShootingEntity.getCommandSenderName() - : "Arrow")); + (WorldServer) this.worldObj, + new GameProfile( + new UUID(0L, 0L), + (tShootingEntity instanceof EntityLivingBase) + ? tShootingEntity.getCommandSenderName() + : "Arrow")); } if (tPlayer != null) { tPlayer.inventory.currentItem = 0; @@ -218,58 +208,54 @@ public class GT_Entity_Arrow extends EntityArrow { tPlayer.setDead(); } } - DamageSource tDamageSource = DamageSource.causeArrowDamage( - this, - tShootingEntity == null ? this : tShootingEntity); + DamageSource tDamageSource = DamageSource + .causeArrowDamage(this, tShootingEntity == null ? this : tShootingEntity); if ((tDamage + tMagicDamage > 0.0F) - && (tVector.entityHit.attackEntityFrom(tDamageSource, tDamage + tMagicDamage))) { + && (tVector.entityHit.attackEntityFrom(tDamageSource, tDamage + tMagicDamage))) { if ((tVector.entityHit instanceof EntityLivingBase tHitLivingEntity)) { if (tHitTimer >= 0) { tVector.entityHit.hurtResistantTime = tHitTimer; } - if (((tVector.entityHit instanceof EntityCreeper)) - && (EnchantmentHelper.getEnchantmentLevel( - Enchantment.fireAspect.effectId, - this.mArrow) > 0)) { + if (((tVector.entityHit instanceof EntityCreeper)) && (EnchantmentHelper + .getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow) > 0)) { ((EntityCreeper) tVector.entityHit).func_146079_cb(); } if (!this.worldObj.isRemote) { - tHitLivingEntity.setArrowCountInEntity( - tHitLivingEntity.getArrowCountInEntity() + 1); + tHitLivingEntity + .setArrowCountInEntity(tHitLivingEntity.getArrowCountInEntity() + 1); } if (tKnockback > 0) { - float tKnockbackDivider = MathHelper.sqrt_double( - this.motionX * this.motionX + this.motionZ * this.motionZ); + float tKnockbackDivider = MathHelper + .sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); if (tKnockbackDivider > 0.0F) { tHitLivingEntity.addVelocity( - this.motionX * tKnockback * 0.6000000238418579D / tKnockbackDivider, - 0.1D, - this.motionZ * tKnockback * 0.6000000238418579D / tKnockbackDivider); + this.motionX * tKnockback * 0.6000000238418579D / tKnockbackDivider, + 0.1D, + this.motionZ * tKnockback * 0.6000000238418579D / tKnockbackDivider); } } GT_Utility.GT_EnchantmentHelper.applyBullshitA( - tHitLivingEntity, - tShootingEntity == null ? this : tShootingEntity, - this.mArrow); + tHitLivingEntity, + tShootingEntity == null ? this : tShootingEntity, + this.mArrow); GT_Utility.GT_EnchantmentHelper.applyBullshitB( - (tShootingEntity instanceof EntityLivingBase) - ? (EntityLivingBase) tShootingEntity - : null, - tHitLivingEntity, - this.mArrow); + (tShootingEntity instanceof EntityLivingBase) ? (EntityLivingBase) tShootingEntity + : null, + tHitLivingEntity, + this.mArrow); if ((tShootingEntity != null) && (tHitLivingEntity != tShootingEntity) - && ((tHitLivingEntity instanceof EntityPlayer)) - && ((tShootingEntity instanceof EntityPlayerMP))) { - ((EntityPlayerMP) tShootingEntity).playerNetServerHandler.sendPacket( - new S2BPacketChangeGameState(6, 0.0F)); + && ((tHitLivingEntity instanceof EntityPlayer)) + && ((tShootingEntity instanceof EntityPlayerMP))) { + ((EntityPlayerMP) tShootingEntity).playerNetServerHandler + .sendPacket(new S2BPacketChangeGameState(6, 0.0F)); } } if (((tShootingEntity instanceof EntityPlayer)) && (tMagicDamage > 0.0F)) { ((EntityPlayer) tShootingEntity).onEnchantmentCritical(tVector.entityHit); } if ((!(tVector.entityHit instanceof EntityEnderman)) - || (((EntityEnderman) tVector.entityHit).getActivePotionEffect(Potion.weakness) - != null)) { + || (((EntityEnderman) tVector.entityHit).getActivePotionEffect(Potion.weakness) + != null)) { if (tFireDamage > 0) { tVector.entityHit.setFire(tFireDamage); } @@ -290,15 +276,13 @@ public class GT_Entity_Arrow extends EntityArrow { this.mHitBlockY = tVector.blockY; this.mHitBlockZ = tVector.blockZ; this.mHitBlock = this.worldObj.getBlock(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); - this.mHitBlockMeta = this.worldObj.getBlockMetadata( - this.mHitBlockX, - this.mHitBlockY, - this.mHitBlockZ); + this.mHitBlockMeta = this.worldObj + .getBlockMetadata(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); this.motionX = ((float) (tVector.hitVec.xCoord - this.posX)); this.motionY = ((float) (tVector.hitVec.yCoord - this.posY)); this.motionZ = ((float) (tVector.hitVec.zCoord - this.posZ)); float f2 = MathHelper.sqrt_double( - this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / f2 * 0.0500000007450581D; this.posY -= this.motionY / f2 * 0.0500000007450581D; this.posZ -= this.motionZ / f2 * 0.0500000007450581D; @@ -308,51 +292,46 @@ public class GT_Entity_Arrow extends EntityArrow { setIsCritical(false); if (this.mHitBlock.getMaterial() != Material.air) { this.mHitBlock.onEntityCollidedWithBlock( - this.worldObj, - this.mHitBlockX, - this.mHitBlockY, - this.mHitBlockZ, - this); + this.worldObj, + this.mHitBlockX, + this.mHitBlockY, + this.mHitBlockZ, + this); } if ((!this.worldObj.isRemote) - && (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow) - > 2)) { - GT_Utility.setCoordsOnFire( - this.worldObj, - this.mHitBlockX, - this.mHitBlockY, - this.mHitBlockZ, - true); + && (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow) > 2)) { + GT_Utility + .setCoordsOnFire(this.worldObj, this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ, true); } if (breaksOnImpact()) { setDead(); } } } - WorldSpawnedEventBuilder.ParticleEventBuilder events = new WorldSpawnedEventBuilder.ParticleEventBuilder().setWorld( - this.worldObj); + WorldSpawnedEventBuilder.ParticleEventBuilder events = new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setWorld(this.worldObj); if (getIsCritical()) { events.setIdentifier(ParticleFX.CRIT) - .setMotion(-this.motionX, -this.motionY + 0.2D, -this.motionZ).<WorldSpawnedEventBuilder - .ParticleEventBuilder>times( - 4, - (x, i) -> x.setPosition( - this.posX + this.motionX * i / 4.0D, - this.posY + this.motionY * i / 4.0D, - this.posZ + this.motionZ * i / 4.0D) - .run()); + .setMotion(-this.motionX, -this.motionY + 0.2D, -this.motionZ).<WorldSpawnedEventBuilder + .ParticleEventBuilder>times( + 4, + (x, i) -> x + .setPosition( + this.posX + this.motionX * i / 4.0D, + this.posY + this.motionY * i / 4.0D, + this.posZ + this.motionZ * i / 4.0D) + .run()); } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; this.rotationYaw = ((float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI)); - for (this.rotationPitch = ((float) (Math.atan2( - this.motionY, - MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ)) * 180.0D - / Math.PI)); this.rotationPitch - this.prevRotationPitch - < -180.0F; this.prevRotationPitch -= 360.0F) {} + for (this.rotationPitch = ((float) (Math + .atan2(this.motionY, MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ)) + * 180.0D + / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {} while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } @@ -367,12 +346,12 @@ public class GT_Entity_Arrow extends EntityArrow { float tFrictionMultiplier = 0.99F; if (isInWater()) { events.setMotion(-this.motionX, -this.motionY + 0.2D, -this.motionZ) - .setIdentifier(ParticleFX.BUBBLE) - .setPosition( - this.posX - this.motionX * 0.25D, - this.posY - this.motionY * 0.25D, - this.posZ - this.motionZ * 0.25D) - .times(4, Runnable::run); + .setIdentifier(ParticleFX.BUBBLE) + .setPosition( + this.posX - this.motionX * 0.25D, + this.posY - this.motionY * 0.25D, + this.posZ - this.motionZ * 0.25D) + .times(4, Runnable::run); tFrictionMultiplier = 0.8F; } if (isWet()) { @@ -422,9 +401,9 @@ public class GT_Entity_Arrow extends EntityArrow { @Override public void onCollideWithPlayer(EntityPlayer aPlayer) { if ((!this.worldObj.isRemote) && (this.inGround) - && (this.arrowShake <= 0) - && (this.canBePickedUp == 1) - && (aPlayer.inventory.addItemStackToInventory(getArrowItem()))) { + && (this.arrowShake <= 0) + && (this.canBePickedUp == 1) + && (aPlayer.inventory.addItemStackToInventory(getArrowItem()))) { playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); aPlayer.onItemPickup(this, 1); setDead(); @@ -432,7 +411,7 @@ public class GT_Entity_Arrow extends EntityArrow { } public int[] onHitEntity(Entity aHitEntity, Entity aShootingEntity, ItemStack aArrow, int aRegularDamage, - int aMagicDamage, int aKnockback, int aFireDamage, int aHitTimer) { + int aMagicDamage, int aKnockback, int aFireDamage, int aHitTimer) { return new int[] { aRegularDamage, aMagicDamage, aKnockback, aFireDamage, aHitTimer }; } |