aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java
diff options
context:
space:
mode:
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.java156
1 files changed, 76 insertions, 80 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 028b3199f7..5afd1b3b47 100644
--- a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java
+++ b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java
@@ -1,13 +1,8 @@
package gregtech.common.entities;
-import com.mojang.authlib.GameProfile;
-import gregtech.api.enums.ParticleFX;
-import gregtech.api.objects.ItemData;
-import gregtech.api.util.GT_OreDictUnificator;
-import gregtech.api.util.GT_Utility;
-import gregtech.api.util.WorldSpawnedEventBuilder;
import java.util.List;
import java.util.UUID;
+
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.Enchantment;
@@ -30,7 +25,16 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
+import com.mojang.authlib.GameProfile;
+
+import gregtech.api.enums.ParticleFX;
+import gregtech.api.objects.ItemData;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.WorldSpawnedEventBuilder;
+
public class GT_Entity_Arrow extends EntityArrow {
+
private int mHitBlockX = -1;
private int mHitBlockY = -1;
private int mHitBlockZ = -1;
@@ -72,10 +76,10 @@ public class GT_Entity_Arrow extends EntityArrow {
Entity tShootingEntity = this.shootingEntity;
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 / 3.141592653589793D));
- this.prevRotationPitch =
- (this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / 3.141592653589793D));
+ this.prevRotationYaw = (this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D
+ / 3.141592653589793D));
+ this.prevRotationPitch = (this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D
+ / 3.141592653589793D));
}
if (this.mTicksAlive++ == 3000) {
setDead();
@@ -83,8 +87,8 @@ 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)))) {
this.inGround = true;
@@ -106,21 +110,19 @@ 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 tAllPotentiallyHitEntities = this.worldObj.getEntitiesWithinAABBExcludingEntity(
this,
- this.boundingBox
- .addCoord(this.motionX, this.motionY, this.motionZ)
- .expand(1.0D, 1.0D, 1.0D));
+ this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double tLargestDistance = 1.7976931348623157E+308D;
for (int i = 0; i < tAllPotentiallyHitEntities.size(); i++) {
Entity entity1 = (Entity) tAllPotentiallyHitEntities.get(i);
@@ -141,9 +143,8 @@ public class GT_Entity_Arrow extends EntityArrow {
}
if ((tVector != null) && ((tVector.entityHit instanceof EntityPlayer))) {
EntityPlayer entityplayer = (EntityPlayer) tVector.entityHit;
- if ((entityplayer.capabilities.disableDamage)
- || (((tShootingEntity instanceof EntityPlayer))
- && (!((EntityPlayer) tShootingEntity).canAttackPlayer(entityplayer)))) {
+ if ((entityplayer.capabilities.disableDamage) || (((tShootingEntity instanceof EntityPlayer))
+ && (!((EntityPlayer) tShootingEntity).canAttackPlayer(entityplayer)))) {
tVector = null;
}
}
@@ -151,19 +152,17 @@ public class GT_Entity_Arrow extends EntityArrow {
if (tVector.entityHit != null) {
ItemData tData = GT_OreDictUnificator.getItemData(this.mArrow);
- float tMagicDamage = (tVector.entityHit instanceof EntityLivingBase)
- ? EnchantmentHelper.func_152377_a(
- this.mArrow, ((EntityLivingBase) tVector.entityHit).getCreatureAttribute())
+ float tMagicDamage = (tVector.entityHit instanceof EntityLivingBase) ? 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)));
+ 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)));
if (getIsCritical()) {
tDamage += this.rand.nextInt((int) (tDamage / 2.0D + 2.0D));
}
@@ -211,28 +210,26 @@ 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))) {
if ((tVector.entityHit instanceof EntityLivingBase)) {
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();
}
EntityLivingBase tHitLivingEntity = (EntityLivingBase) tVector.entityHit;
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,
@@ -250,12 +247,11 @@ public class GT_Entity_Arrow extends EntityArrow {
: null,
tHitLivingEntity,
this.mArrow);
- if ((tShootingEntity != null)
- && (tHitLivingEntity != tShootingEntity)
+ if ((tShootingEntity != null) && (tHitLivingEntity != tShootingEntity)
&& ((tHitLivingEntity instanceof EntityPlayer))
&& ((tShootingEntity instanceof EntityPlayerMP))) {
- ((EntityPlayerMP) tShootingEntity)
- .playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
+ ((EntityPlayerMP) tShootingEntity).playerNetServerHandler
+ .sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
}
if (((tShootingEntity instanceof EntityPlayer)) && (tMagicDamage > 0.0F)) {
@@ -284,8 +280,8 @@ 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));
@@ -300,30 +296,41 @@ 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);
+ 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;
@@ -331,12 +338,10 @@ public class GT_Entity_Arrow extends EntityArrow {
this.rotationYaw = ((float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / 3.141592653589793D));
for (this.rotationPitch = ((float) (Math.atan2(
- this.motionY,
- MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ))
- * 180.0D
- / 3.141592653589793D));
- this.rotationPitch - this.prevRotationPitch < -180.0F;
- this.prevRotationPitch -= 360.0F) {}
+ this.motionY,
+ MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ)) * 180.0D
+ / 3.141592653589793D)); this.rotationPitch - this.prevRotationPitch
+ < -180.0F; this.prevRotationPitch -= 360.0F) {}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
@@ -350,8 +355,7 @@ public class GT_Entity_Arrow extends EntityArrow {
this.rotationYaw = (this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F);
float tFrictionMultiplier = 0.99F;
if (isInWater()) {
- events.setMotion(-this.motionX, -this.motionY + 0.2D, -this.motionZ)
- .setIdentifier(ParticleFX.BUBBLE)
+ 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,
@@ -405,8 +409,7 @@ public class GT_Entity_Arrow extends EntityArrow {
@Override
public void onCollideWithPlayer(EntityPlayer aPlayer) {
- if ((!this.worldObj.isRemote)
- && (this.inGround)
+ if ((!this.worldObj.isRemote) && (this.inGround)
&& (this.arrowShake <= 0)
&& (this.canBePickedUp == 1)
&& (aPlayer.inventory.addItemStackToInventory(getArrowItem()))) {
@@ -416,16 +419,9 @@ 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) {
- return new int[] {aRegularDamage, aMagicDamage, aKnockback, aFireDamage, aHitTimer};
+ public int[] onHitEntity(Entity aHitEntity, Entity aShootingEntity, ItemStack aArrow, int aRegularDamage,
+ int aMagicDamage, int aKnockback, int aFireDamage, int aHitTimer) {
+ return new int[] { aRegularDamage, aMagicDamage, aKnockback, aFireDamage, aHitTimer };
}
public ItemStack getArrowItem() {