From a1504799f44ba2debdfef06317f24e7f9c1129d6 Mon Sep 17 00:00:00 2001 From: aerospark Date: Tue, 23 Jun 2015 15:29:05 -0700 Subject: strip linenumbers --- .../gregtech/common/entities/GT_Entity_Arrow.java | 782 ++++++++++----------- .../common/entities/GT_Entity_Arrow_Potion.java | 142 ++-- 2 files changed, 462 insertions(+), 462 deletions(-) (limited to 'main/java/gregtech/common/entities') diff --git a/main/java/gregtech/common/entities/GT_Entity_Arrow.java b/main/java/gregtech/common/entities/GT_Entity_Arrow.java index 63a319f01a..83bb16d92b 100644 --- a/main/java/gregtech/common/entities/GT_Entity_Arrow.java +++ b/main/java/gregtech/common/entities/GT_Entity_Arrow.java @@ -1,394 +1,394 @@ -/* 1: */ package gregtech.common.entities; -/* 2: */ -/* 3: */ import com.mojang.authlib.GameProfile; -/* 4: */ import gregtech.api.enums.Materials; -/* 5: */ import gregtech.api.objects.ItemData; -/* 6: */ import gregtech.api.objects.MaterialStack; -/* 7: */ import gregtech.api.util.GT_OreDictUnificator; -/* 8: */ import gregtech.api.util.GT_Utility; -/* 9: */ import gregtech.api.util.GT_Utility.GT_EnchantmentHelper; -/* 10: */ import java.util.List; -/* 11: */ import java.util.Random; -/* 12: */ import java.util.UUID; -/* 13: */ import net.minecraft.block.Block; -/* 14: */ import net.minecraft.block.material.Material; -/* 15: */ import net.minecraft.enchantment.Enchantment; -/* 16: */ import net.minecraft.enchantment.EnchantmentHelper; -/* 17: */ import net.minecraft.entity.Entity; -/* 18: */ import net.minecraft.entity.EntityLivingBase; -/* 19: */ import net.minecraft.entity.monster.EntityCreeper; -/* 20: */ import net.minecraft.entity.monster.EntityEnderman; -/* 21: */ import net.minecraft.entity.player.EntityPlayer; -/* 22: */ import net.minecraft.entity.player.EntityPlayerMP; -/* 23: */ import net.minecraft.entity.player.InventoryPlayer; -/* 24: */ import net.minecraft.entity.player.PlayerCapabilities; -/* 25: */ import net.minecraft.entity.projectile.EntityArrow; -/* 26: */ import net.minecraft.init.Blocks; -/* 27: */ import net.minecraft.init.Items; -/* 28: */ import net.minecraft.item.ItemStack; -/* 29: */ import net.minecraft.nbt.NBTTagCompound; -/* 30: */ import net.minecraft.network.NetHandlerPlayServer; -/* 31: */ import net.minecraft.network.play.server.S2BPacketChangeGameState; -/* 32: */ import net.minecraft.potion.Potion; -/* 33: */ import net.minecraft.util.AxisAlignedBB; -/* 34: */ import net.minecraft.util.DamageSource; -/* 35: */ import net.minecraft.util.MathHelper; -/* 36: */ import net.minecraft.util.MovingObjectPosition; -/* 37: */ import net.minecraft.util.Vec3; -/* 38: */ import net.minecraft.world.World; -/* 39: */ import net.minecraft.world.WorldServer; -/* 40: */ import net.minecraftforge.common.util.FakePlayerFactory; -/* 41: */ -/* 42: */ public class GT_Entity_Arrow -/* 43: */ extends EntityArrow -/* 44: */ { -/* 45: 36 */ private int mHitBlockX = -1; -/* 46: 37 */ private int mHitBlockY = -1; -/* 47: 38 */ private int mHitBlockZ = -1; -/* 48: 39 */ private Block mHitBlock = Blocks.air; -/* 49: 40 */ private int mHitBlockMeta = 0; -/* 50: 41 */ private boolean inGround = false; -/* 51: 42 */ private int mTicksAlive = 0; -/* 52: 43 */ private int ticksInAir = 0; -/* 53: 44 */ private int mKnockback = 0; -/* 54: 46 */ private ItemStack mArrow = null; -/* 55: */ -/* 56: */ public GT_Entity_Arrow(World aWorld) -/* 57: */ { -/* 58: 49 */ super(aWorld); -/* 59: */ } -/* 60: */ -/* 61: */ public GT_Entity_Arrow(World aWorld, double aX, double aY, double aZ) -/* 62: */ { -/* 63: 53 */ super(aWorld, aX, aY, aZ); -/* 64: */ } -/* 65: */ -/* 66: */ public GT_Entity_Arrow(World aWorld, EntityLivingBase aEntity, float aSpeed) -/* 67: */ { -/* 68: 57 */ super(aWorld, aEntity, aSpeed); -/* 69: */ } -/* 70: */ -/* 71: */ public GT_Entity_Arrow(EntityArrow aArrow, ItemStack aStack) -/* 72: */ { -/* 73: 61 */ super(aArrow.worldObj); -/* 74: 62 */ NBTTagCompound tNBT = new NBTTagCompound(); -/* 75: 63 */ aArrow.writeToNBT(tNBT); -/* 76: 64 */ readFromNBT(tNBT); -/* 77: 65 */ setArrowItem(aStack); -/* 78: */ } -/* 79: */ -/* 80: */ public void onUpdate() -/* 81: */ { -/* 82: 70 */ onEntityUpdate(); -/* 83: 71 */ if ((this.mArrow == null) && (!this.worldObj.isRemote)) -/* 84: */ { -/* 85: 72 */ setDead(); -/* 86: 73 */ return; -/* 87: */ } -/* 88: 76 */ Entity tShootingEntity = this.shootingEntity; -/* 89: 78 */ if ((this.prevRotationPitch == 0.0F) && (this.prevRotationYaw == 0.0F)) -/* 90: */ { -/* 91: 79 */ float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); -/* 92: 80 */ this.prevRotationYaw = (this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / 3.141592653589793D)); -/* 93: 81 */ this.prevRotationPitch = (this.rotationPitch = (float)(Math.atan2(this.motionY, f) * 180.0D / 3.141592653589793D)); -/* 94: */ } -/* 95: 84 */ if (this.mTicksAlive++ == 3000) { -/* 96: 84 */ setDead(); -/* 97: */ } -/* 98: 86 */ Block tBlock = this.worldObj.getBlock(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); -/* 99: 88 */ if (tBlock.getMaterial() != Material.air) -/* 100: */ { -/* 101: 89 */ tBlock.setBlockBoundsBasedOnState(this.worldObj, this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); -/* 102: 90 */ AxisAlignedBB axisalignedbb = tBlock.getCollisionBoundingBoxFromPool(this.worldObj, this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); -/* 103: 91 */ if ((axisalignedbb != null) && (axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))) { -/* 104: 91 */ this.inGround = true; -/* 105: */ } -/* 106: */ } -/* 107: 94 */ if (this.arrowShake > 0) { -/* 108: 94 */ this.arrowShake -= 1; -/* 109: */ } -/* 110: 96 */ if (this.inGround) -/* 111: */ { -/* 112: 97 */ int j = this.worldObj.getBlockMetadata(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); -/* 113: 98 */ if ((tBlock != this.mHitBlock) || (j != this.mHitBlockMeta)) -/* 114: */ { -/* 115: 99 */ this.inGround = false; -/* 116:100 */ this.motionX *= this.rand.nextFloat() * 0.2F; -/* 117:101 */ this.motionY *= this.rand.nextFloat() * 0.2F; -/* 118:102 */ this.motionZ *= this.rand.nextFloat() * 0.2F; -/* 119:103 */ this.mTicksAlive = 0; -/* 120:104 */ this.ticksInAir = 0; -/* 121: */ } -/* 122: */ } -/* 123: */ else -/* 124: */ { -/* 125:107 */ this.ticksInAir += 1; -/* 126:108 */ Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); -/* 127:109 */ Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); -/* 128:110 */ MovingObjectPosition tVector = this.worldObj.func_147447_a(vec31, vec3, false, true, false); -/* 129:111 */ vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); -/* 130:112 */ vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); -/* 131:114 */ if (tVector != null) { -/* 132:114 */ vec3 = Vec3.createVectorHelper(tVector.hitVec.xCoord, tVector.hitVec.yCoord, tVector.hitVec.zCoord); -/* 133: */ } -/* 134:116 */ Entity tHitEntity = null; -/* 135:117 */ List tAllPotentiallyHitEntities = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); -/* 136:118 */ double tLargestDistance = 1.7976931348623157E+308D; -/* 137:120 */ for (int i = 0; i < tAllPotentiallyHitEntities.size(); i++) -/* 138: */ { -/* 139:121 */ Entity entity1 = (Entity)tAllPotentiallyHitEntities.get(i); -/* 140:123 */ if ((entity1.canBeCollidedWith()) && ((entity1 != tShootingEntity) || (this.ticksInAir >= 5))) -/* 141: */ { -/* 142:124 */ AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(0.3D, 0.3D, 0.3D); -/* 143:125 */ MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); -/* 144:127 */ if (movingobjectposition1 != null) -/* 145: */ { -/* 146:128 */ double tDistance = vec31.distanceTo(movingobjectposition1.hitVec); -/* 147:130 */ if (tDistance < tLargestDistance) -/* 148: */ { -/* 149:131 */ tHitEntity = entity1; -/* 150:132 */ tLargestDistance = tDistance; -/* 151: */ } -/* 152: */ } -/* 153: */ } -/* 154: */ } -/* 155:138 */ if (tHitEntity != null) { -/* 156:138 */ tVector = new MovingObjectPosition(tHitEntity); -/* 157: */ } -/* 158:140 */ if ((tVector != null) && (tVector.entityHit != null) && ((tVector.entityHit instanceof EntityPlayer))) -/* 159: */ { -/* 160:141 */ EntityPlayer entityplayer = (EntityPlayer)tVector.entityHit; -/* 161:142 */ if ((entityplayer.capabilities.disableDamage) || (((tShootingEntity instanceof EntityPlayer)) && (!((EntityPlayer)tShootingEntity).canAttackPlayer(entityplayer)))) { -/* 162:142 */ tVector = null; -/* 163: */ } -/* 164: */ } -/* 165:145 */ if (tVector != null) { -/* 166:146 */ if (tVector.entityHit != null) -/* 167: */ { -/* 168:147 */ ItemData tData = GT_OreDictUnificator.getItemData(this.mArrow); -/* 169: */ -/* 170: */ -/* 171:150 */ float tMagicDamage = (tVector.entityHit instanceof EntityLivingBase) ? EnchantmentHelper.func_152377_a(this.mArrow, ((EntityLivingBase)tVector.entityHit).getCreatureAttribute()) : 0.0F; -/* 172:151 */ 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))); -/* 173:153 */ if (getIsCritical()) { -/* 174:153 */ tDamage += this.rand.nextInt((int)(tDamage / 2.0D + 2.0D)); -/* 175: */ } -/* 176:156 */ int tFireDamage = (isBurning() ? 5 : 0) + 4 * EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow); -/* 177:157 */ int tKnockback = this.mKnockback + EnchantmentHelper.getEnchantmentLevel(Enchantment.knockback.effectId, this.mArrow); -/* 178:158 */ int tHitTimer = -1; -/* 179: */ -/* 180:160 */ 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); -/* 181:162 */ if (tDamages != null) -/* 182: */ { -/* 183:163 */ tDamage = tDamages[0] / 2.0F; -/* 184:164 */ tMagicDamage = tDamages[1] / 2.0F; -/* 185:165 */ tKnockback = tDamages[2]; -/* 186:166 */ tFireDamage = tDamages[3]; -/* 187:167 */ tHitTimer = tDamages[4]; -/* 188:169 */ if ((tFireDamage > 0) && (!(tVector.entityHit instanceof EntityEnderman))) { -/* 189:169 */ tVector.entityHit.setFire(tFireDamage); -/* 190: */ } -/* 191:171 */ if ((!(tHitEntity instanceof EntityPlayer)) && (EnchantmentHelper.getEnchantmentLevel(Enchantment.looting.effectId, this.mArrow) > 0)) -/* 192: */ { -/* 193:172 */ EntityPlayer tPlayer = null; -/* 194:173 */ if ((this.worldObj instanceof WorldServer)) { -/* 195:173 */ tPlayer = FakePlayerFactory.get((WorldServer)this.worldObj, new GameProfile(new UUID(0L, 0L), (tShootingEntity instanceof EntityLivingBase) ? ((EntityLivingBase)tShootingEntity).getCommandSenderName() : "Arrow")); -/* 196: */ } -/* 197:174 */ if (tPlayer != null) -/* 198: */ { -/* 199:175 */ tPlayer.inventory.currentItem = 0; -/* 200:176 */ tPlayer.inventory.setInventorySlotContents(0, getArrowItem()); -/* 201:177 */ tShootingEntity = tPlayer; -/* 202:178 */ tPlayer.setDead(); -/* 203: */ } -/* 204: */ } -/* 205:182 */ DamageSource tDamageSource = DamageSource.causeArrowDamage(this, tShootingEntity == null ? this : tShootingEntity); -/* 206:184 */ if ((tDamage + tMagicDamage > 0.0F) && (tVector.entityHit.attackEntityFrom(tDamageSource, tDamage + tMagicDamage))) -/* 207: */ { -/* 208:185 */ if ((tVector.entityHit instanceof EntityLivingBase)) -/* 209: */ { -/* 210:186 */ if (tHitTimer >= 0) { -/* 211:186 */ tVector.entityHit.hurtResistantTime = tHitTimer; -/* 212: */ } -/* 213:188 */ if (((tVector.entityHit instanceof EntityCreeper)) && (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow) > 0)) { -/* 214:188 */ ((EntityCreeper)tVector.entityHit).func_146079_cb(); -/* 215: */ } -/* 216:190 */ EntityLivingBase tHitLivingEntity = (EntityLivingBase)tVector.entityHit; -/* 217:192 */ if (!this.worldObj.isRemote) { -/* 218:192 */ tHitLivingEntity.setArrowCountInEntity(tHitLivingEntity.getArrowCountInEntity() + 1); -/* 219: */ } -/* 220:194 */ if (tKnockback > 0) -/* 221: */ { -/* 222:195 */ float tKnockbackDivider = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); -/* 223:196 */ if (tKnockbackDivider > 0.0F) { -/* 224:196 */ tHitLivingEntity.addVelocity(this.motionX * tKnockback * 0.6000000238418579D / tKnockbackDivider, 0.1D, this.motionZ * tKnockback * 0.6000000238418579D / tKnockbackDivider); -/* 225: */ } -/* 226: */ } -/* 227:199 */ GT_Utility.GT_EnchantmentHelper.applyBullshitA(tHitLivingEntity, tShootingEntity == null ? this : tShootingEntity, this.mArrow); -/* 228:200 */ GT_Utility.GT_EnchantmentHelper.applyBullshitB((tShootingEntity instanceof EntityLivingBase) ? (EntityLivingBase)tShootingEntity : null, tHitLivingEntity, this.mArrow); -/* 229:202 */ if ((tShootingEntity != null) && (tHitLivingEntity != tShootingEntity) && ((tHitLivingEntity instanceof EntityPlayer)) && ((tShootingEntity instanceof EntityPlayerMP))) { -/* 230:203 */ ((EntityPlayerMP)tShootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); -/* 231: */ } -/* 232: */ } -/* 233:207 */ if (((tShootingEntity instanceof EntityPlayer)) && (tMagicDamage > 0.0F)) { -/* 234:207 */ ((EntityPlayer)tShootingEntity).onEnchantmentCritical(tVector.entityHit); -/* 235: */ } -/* 236:209 */ if ((!(tVector.entityHit instanceof EntityEnderman)) || (((EntityEnderman)tVector.entityHit).getActivePotionEffect(Potion.weakness) != null)) -/* 237: */ { -/* 238:210 */ if (tFireDamage > 0) { -/* 239:210 */ tVector.entityHit.setFire(tFireDamage); -/* 240: */ } -/* 241:211 */ playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); -/* 242:212 */ setDead(); -/* 243: */ } -/* 244: */ } -/* 245: */ else -/* 246: */ { -/* 247:215 */ this.motionX *= -0.1000000014901161D; -/* 248:216 */ this.motionY *= -0.1000000014901161D; -/* 249:217 */ this.motionZ *= -0.1000000014901161D; -/* 250:218 */ this.rotationYaw += 180.0F; -/* 251:219 */ this.prevRotationYaw += 180.0F; -/* 252:220 */ this.ticksInAir = 0; -/* 253: */ } -/* 254: */ } -/* 255: */ } -/* 256: */ else -/* 257: */ { -/* 258:224 */ this.mHitBlockX = tVector.blockX; -/* 259:225 */ this.mHitBlockY = tVector.blockY; -/* 260:226 */ this.mHitBlockZ = tVector.blockZ; -/* 261:227 */ this.mHitBlock = this.worldObj.getBlock(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); -/* 262:228 */ this.mHitBlockMeta = this.worldObj.getBlockMetadata(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); -/* 263:229 */ this.motionX = ((float)(tVector.hitVec.xCoord - this.posX)); -/* 264:230 */ this.motionY = ((float)(tVector.hitVec.yCoord - this.posY)); -/* 265:231 */ this.motionZ = ((float)(tVector.hitVec.zCoord - this.posZ)); -/* 266:232 */ float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); -/* 267:233 */ this.posX -= this.motionX / f2 * 0.0500000007450581D; -/* 268:234 */ this.posY -= this.motionY / f2 * 0.0500000007450581D; -/* 269:235 */ this.posZ -= this.motionZ / f2 * 0.0500000007450581D; -/* 270:236 */ playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); -/* 271:237 */ this.inGround = true; -/* 272:238 */ this.arrowShake = 7; -/* 273:239 */ setIsCritical(false); -/* 274:241 */ if (this.mHitBlock.getMaterial() != Material.air) { -/* 275:241 */ this.mHitBlock.onEntityCollidedWithBlock(this.worldObj, this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ, this); -/* 276: */ } -/* 277:243 */ if ((!this.worldObj.isRemote) && (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow) > 2)) { -/* 278:243 */ GT_Utility.setCoordsOnFire(this.worldObj, this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ, true); -/* 279: */ } -/* 280:245 */ if (breaksOnImpact()) { -/* 281:245 */ setDead(); -/* 282: */ } -/* 283: */ } -/* 284: */ } -/* 285:249 */ if (getIsCritical()) { -/* 286:249 */ for (int i = 0; i < 4; i++) { -/* 287:249 */ this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); -/* 288: */ } -/* 289: */ } -/* 290:251 */ this.posX += this.motionX;this.posY += this.motionY;this.posZ += this.motionZ; -/* 291: */ -/* 292:253 */ this.rotationYaw = ((float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / 3.141592653589793D)); -/* 293:255 */ 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) {} -/* 294:257 */ while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { -/* 295:257 */ this.prevRotationPitch += 360.0F; -/* 296: */ } -/* 297:258 */ while (this.rotationYaw - this.prevRotationYaw < -180.0F) { -/* 298:258 */ this.prevRotationYaw -= 360.0F; -/* 299: */ } -/* 300:259 */ while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { -/* 301:259 */ this.prevRotationYaw += 360.0F; -/* 302: */ } -/* 303:261 */ this.rotationPitch = (this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F); -/* 304:262 */ this.rotationYaw = (this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F); -/* 305:263 */ float tFrictionMultiplier = 0.99F; -/* 306:265 */ if (isInWater()) -/* 307: */ { -/* 308:266 */ for (int l = 0; l < 4; l++) { -/* 309:266 */ this.worldObj.spawnParticle("bubble", this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ); -/* 310: */ } -/* 311:267 */ tFrictionMultiplier = 0.8F; -/* 312: */ } -/* 313:270 */ if (isWet()) { -/* 314:270 */ extinguish(); -/* 315: */ } -/* 316:272 */ this.motionX *= tFrictionMultiplier; -/* 317:273 */ this.motionY *= tFrictionMultiplier; -/* 318:274 */ this.motionZ *= tFrictionMultiplier; -/* 319:275 */ this.motionY -= 0.0500000007450581D; -/* 320:276 */ setPosition(this.posX, this.posY, this.posZ); -/* 321:277 */ func_145775_I(); -/* 322: */ } -/* 323: */ } -/* 324: */ -/* 325: */ public void writeEntityToNBT(NBTTagCompound aNBT) -/* 326: */ { -/* 327:283 */ super.writeEntityToNBT(aNBT); -/* 328:284 */ aNBT.setShort("xTile", (short)this.mHitBlockX); -/* 329:285 */ aNBT.setShort("yTile", (short)this.mHitBlockY); -/* 330:286 */ aNBT.setShort("zTile", (short)this.mHitBlockZ); -/* 331:287 */ aNBT.setShort("life", (short)this.mTicksAlive); -/* 332:288 */ aNBT.setByte("inTile", (byte)Block.getIdFromBlock(this.mHitBlock)); -/* 333:289 */ aNBT.setByte("inData", (byte)this.mHitBlockMeta); -/* 334:290 */ aNBT.setByte("shake", (byte)this.arrowShake); -/* 335:291 */ aNBT.setByte("inGround", (byte)(this.inGround ? 1 : 0)); -/* 336:292 */ aNBT.setByte("pickup", (byte)this.canBePickedUp); -/* 337:293 */ aNBT.setDouble("damage", getDamage()); -/* 338:294 */ aNBT.setTag("mArrow", this.mArrow == null ? null : this.mArrow.writeToNBT(new NBTTagCompound())); -/* 339: */ } -/* 340: */ -/* 341: */ public void readEntityFromNBT(NBTTagCompound aNBT) -/* 342: */ { -/* 343:299 */ super.readEntityFromNBT(aNBT); -/* 344:300 */ this.mHitBlockX = aNBT.getShort("xTile"); -/* 345:301 */ this.mHitBlockY = aNBT.getShort("yTile"); -/* 346:302 */ this.mHitBlockZ = aNBT.getShort("zTile"); -/* 347:303 */ this.mTicksAlive = aNBT.getShort("life"); -/* 348:304 */ this.mHitBlock = Block.getBlockById(aNBT.getByte("inTile") & 0xFF); -/* 349:305 */ this.mHitBlockMeta = (aNBT.getByte("inData") & 0xFF); -/* 350:306 */ this.arrowShake = (aNBT.getByte("shake") & 0xFF); -/* 351:307 */ this.inGround = (aNBT.getByte("inGround") == 1); -/* 352:308 */ setDamage(aNBT.getDouble("damage")); -/* 353:309 */ this.canBePickedUp = aNBT.getByte("pickup"); -/* 354:310 */ this.mArrow = GT_Utility.loadItem(aNBT, "mArrow"); -/* 355: */ } -/* 356: */ -/* 357: */ public void onCollideWithPlayer(EntityPlayer aPlayer) -/* 358: */ { -/* 359:315 */ if ((!this.worldObj.isRemote) && (this.inGround) && (this.arrowShake <= 0) && (this.canBePickedUp == 1) && (aPlayer.inventory.addItemStackToInventory(getArrowItem()))) -/* 360: */ { -/* 361:316 */ playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); -/* 362:317 */ aPlayer.onItemPickup(this, 1); -/* 363:318 */ setDead(); -/* 364: */ } -/* 365: */ } -/* 366: */ -/* 367: */ public int[] onHitEntity(Entity aHitEntity, Entity aShootingEntity, ItemStack aArrow, int aRegularDamage, int aMagicDamage, int aKnockback, int aFireDamage, int aHitTimer) -/* 368: */ { -/* 369:333 */ return new int[] { aRegularDamage, aMagicDamage, aKnockback, aFireDamage, aHitTimer }; -/* 370: */ } -/* 371: */ -/* 372: */ public void setArrowItem(ItemStack aStack) -/* 373: */ { -/* 374:337 */ this.mArrow = GT_Utility.updateItemStack(GT_Utility.copyAmount(1L, new Object[] { aStack })); -/* 375: */ } -/* 376: */ -/* 377: */ public ItemStack getArrowItem() -/* 378: */ { -/* 379:341 */ return GT_Utility.copy(new Object[] { this.mArrow }); -/* 380: */ } -/* 381: */ -/* 382: */ public boolean breaksOnImpact() -/* 383: */ { -/* 384:345 */ return false; -/* 385: */ } -/* 386: */ -/* 387: */ public void setKnockbackStrength(int aKnockback) -/* 388: */ { -/* 389:350 */ this.mKnockback = aKnockback; -/* 390: */ } -/* 391: */ } +package gregtech.common.entities; + +import com.mojang.authlib.GameProfile; +import gregtech.api.enums.Materials; +import gregtech.api.objects.ItemData; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Utility.GT_EnchantmentHelper; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.player.PlayerCapabilities; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.potion.Potion; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.FakePlayerFactory; + +public class GT_Entity_Arrow + extends EntityArrow +{ + private int mHitBlockX = -1; + private int mHitBlockY = -1; + private int mHitBlockZ = -1; + private Block mHitBlock = Blocks.air; + private int mHitBlockMeta = 0; + private boolean inGround = false; + private int mTicksAlive = 0; + private int ticksInAir = 0; + private int mKnockback = 0; + private ItemStack mArrow = null; + + public GT_Entity_Arrow(World aWorld) + { + super(aWorld); + } + + public GT_Entity_Arrow(World aWorld, double aX, double aY, double aZ) + { + super(aWorld, aX, aY, aZ); + } + + public GT_Entity_Arrow(World aWorld, EntityLivingBase aEntity, float aSpeed) + { + super(aWorld, aEntity, aSpeed); + } + + public GT_Entity_Arrow(EntityArrow aArrow, ItemStack aStack) + { + super(aArrow.worldObj); + NBTTagCompound tNBT = new NBTTagCompound(); + aArrow.writeToNBT(tNBT); + readFromNBT(tNBT); + setArrowItem(aStack); + } + + public void onUpdate() + { + onEntityUpdate(); + if ((this.mArrow == null) && (!this.worldObj.isRemote)) + { + setDead(); + return; + } + 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)); + } + if (this.mTicksAlive++ == 3000) { + setDead(); + } + 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); + if ((axisalignedbb != null) && (axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))) { + this.inGround = true; + } + } + if (this.arrowShake > 0) { + this.arrowShake -= 1; + } + if (this.inGround) + { + int j = this.worldObj.getBlockMetadata(this.mHitBlockX, this.mHitBlockY, this.mHitBlockZ); + if ((tBlock != this.mHitBlock) || (j != this.mHitBlockMeta)) + { + this.inGround = false; + this.motionX *= this.rand.nextFloat() * 0.2F; + this.motionY *= this.rand.nextFloat() * 0.2F; + this.motionZ *= this.rand.nextFloat() * 0.2F; + this.mTicksAlive = 0; + this.ticksInAir = 0; + } + } + 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); + 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); + 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)); + double tLargestDistance = 1.7976931348623157E+308D; + for (int i = 0; i < tAllPotentiallyHitEntities.size(); i++) + { + Entity entity1 = (Entity)tAllPotentiallyHitEntities.get(i); + if ((entity1.canBeCollidedWith()) && ((entity1 != tShootingEntity) || (this.ticksInAir >= 5))) + { + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(0.3D, 0.3D, 0.3D); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); + if (movingobjectposition1 != null) + { + double tDistance = vec31.distanceTo(movingobjectposition1.hitVec); + if (tDistance < tLargestDistance) + { + tHitEntity = entity1; + tLargestDistance = tDistance; + } + } + } + } + if (tHitEntity != null) { + tVector = new MovingObjectPosition(tHitEntity); + } + if ((tVector != null) && (tVector.entityHit != null) && ((tVector.entityHit instanceof EntityPlayer))) + { + EntityPlayer entityplayer = (EntityPlayer)tVector.entityHit; + if ((entityplayer.capabilities.disableDamage) || (((tShootingEntity instanceof EntityPlayer)) && (!((EntityPlayer)tShootingEntity).canAttackPlayer(entityplayer)))) { + tVector = null; + } + } + if (tVector != null) { + 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()) : 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)); + } + int tFireDamage = (isBurning() ? 5 : 0) + 4 * EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, this.mArrow); + int tKnockback = this.mKnockback + 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); + if (tDamages != null) + { + tDamage = tDamages[0] / 2.0F; + tMagicDamage = tDamages[1] / 2.0F; + tKnockback = tDamages[2]; + tFireDamage = tDamages[3]; + tHitTimer = tDamages[4]; + if ((tFireDamage > 0) && (!(tVector.entityHit instanceof EntityEnderman))) { + tVector.entityHit.setFire(tFireDamage); + } + if ((!(tHitEntity instanceof EntityPlayer)) && (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) ? ((EntityLivingBase)tShootingEntity).getCommandSenderName() : "Arrow")); + } + if (tPlayer != null) + { + tPlayer.inventory.currentItem = 0; + tPlayer.inventory.setInventorySlotContents(0, getArrowItem()); + tShootingEntity = tPlayer; + tPlayer.setDead(); + } + } + 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)) { + ((EntityCreeper)tVector.entityHit).func_146079_cb(); + } + EntityLivingBase tHitLivingEntity = (EntityLivingBase)tVector.entityHit; + if (!this.worldObj.isRemote) { + tHitLivingEntity.setArrowCountInEntity(tHitLivingEntity.getArrowCountInEntity() + 1); + } + if (tKnockback > 0) + { + 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); + } + } + GT_Utility.GT_EnchantmentHelper.applyBullshitA(tHitLivingEntity, tShootingEntity == null ? this : tShootingEntity, this.mArrow); + GT_Utility.GT_EnchantmentHelper.applyBullshitB((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)); + } + } + if (((tShootingEntity instanceof EntityPlayer)) && (tMagicDamage > 0.0F)) { + ((EntityPlayer)tShootingEntity).onEnchantmentCritical(tVector.entityHit); + } + if ((!(tVector.entityHit instanceof EntityEnderman)) || (((EntityEnderman)tVector.entityHit).getActivePotionEffect(Potion.weakness) != null)) + { + if (tFireDamage > 0) { + tVector.entityHit.setFire(tFireDamage); + } + playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + setDead(); + } + } + else + { + this.motionX *= -0.1000000014901161D; + this.motionY *= -0.1000000014901161D; + this.motionZ *= -0.1000000014901161D; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } + } + else + { + this.mHitBlockX = tVector.blockX; + 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.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.posX -= this.motionX / f2 * 0.0500000007450581D; + this.posY -= this.motionY / f2 * 0.0500000007450581D; + this.posZ -= this.motionZ / f2 * 0.0500000007450581D; + playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; + setIsCritical(false); + if (this.mHitBlock.getMaterial() != Material.air) { + this.mHitBlock.onEntityCollidedWithBlock(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); + } + if (breaksOnImpact()) { + setDead(); + } + } + } + if (getIsCritical()) { + for (int i = 0; i < 4; i++) { + this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); + } + } + this.posX += this.motionX;this.posY += this.motionY;this.posZ += this.motionZ; + + 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) {} + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { + this.prevRotationPitch += 360.0F; + } + while (this.rotationYaw - this.prevRotationYaw < -180.0F) { + this.prevRotationYaw -= 360.0F; + } + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { + this.prevRotationYaw += 360.0F; + } + this.rotationPitch = (this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F); + this.rotationYaw = (this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F); + float tFrictionMultiplier = 0.99F; + if (isInWater()) + { + for (int l = 0; l < 4; l++) { + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ); + } + tFrictionMultiplier = 0.8F; + } + if (isWet()) { + extinguish(); + } + this.motionX *= tFrictionMultiplier; + this.motionY *= tFrictionMultiplier; + this.motionZ *= tFrictionMultiplier; + this.motionY -= 0.0500000007450581D; + setPosition(this.posX, this.posY, this.posZ); + func_145775_I(); + } + } + + public void writeEntityToNBT(NBTTagCompound aNBT) + { + super.writeEntityToNBT(aNBT); + aNBT.setShort("xTile", (short)this.mHitBlockX); + aNBT.setShort("yTile", (short)this.mHitBlockY); + aNBT.setShort("zTile", (short)this.mHitBlockZ); + aNBT.setShort("life", (short)this.mTicksAlive); + aNBT.setByte("inTile", (byte)Block.getIdFromBlock(this.mHitBlock)); + aNBT.setByte("inData", (byte)this.mHitBlockMeta); + aNBT.setByte("shake", (byte)this.arrowShake); + aNBT.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + aNBT.setByte("pickup", (byte)this.canBePickedUp); + aNBT.setDouble("damage", getDamage()); + aNBT.setTag("mArrow", this.mArrow == null ? null : this.mArrow.writeToNBT(new NBTTagCompound())); + } + + public void readEntityFromNBT(NBTTagCompound aNBT) + { + super.readEntityFromNBT(aNBT); + this.mHitBlockX = aNBT.getShort("xTile"); + this.mHitBlockY = aNBT.getShort("yTile"); + this.mHitBlockZ = aNBT.getShort("zTile"); + this.mTicksAlive = aNBT.getShort("life"); + this.mHitBlock = Block.getBlockById(aNBT.getByte("inTile") & 0xFF); + this.mHitBlockMeta = (aNBT.getByte("inData") & 0xFF); + this.arrowShake = (aNBT.getByte("shake") & 0xFF); + this.inGround = (aNBT.getByte("inGround") == 1); + setDamage(aNBT.getDouble("damage")); + this.canBePickedUp = aNBT.getByte("pickup"); + this.mArrow = GT_Utility.loadItem(aNBT, "mArrow"); + } + + public void onCollideWithPlayer(EntityPlayer aPlayer) + { + if ((!this.worldObj.isRemote) && (this.inGround) && (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(); + } + } + + 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 void setArrowItem(ItemStack aStack) + { + this.mArrow = GT_Utility.updateItemStack(GT_Utility.copyAmount(1L, new Object[] { aStack })); + } + + public ItemStack getArrowItem() + { + return GT_Utility.copy(new Object[] { this.mArrow }); + } + + public boolean breaksOnImpact() + { + return false; + } + + public void setKnockbackStrength(int aKnockback) + { + this.mKnockback = aKnockback; + } +} /* Location: F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar diff --git a/main/java/gregtech/common/entities/GT_Entity_Arrow_Potion.java b/main/java/gregtech/common/entities/GT_Entity_Arrow_Potion.java index 8da5f11206..1deb2f3794 100644 --- a/main/java/gregtech/common/entities/GT_Entity_Arrow_Potion.java +++ b/main/java/gregtech/common/entities/GT_Entity_Arrow_Potion.java @@ -1,74 +1,74 @@ -/* 1: */ package gregtech.common.entities; -/* 2: */ -/* 3: */ import java.util.Random; -/* 4: */ import net.minecraft.entity.Entity; -/* 5: */ import net.minecraft.entity.EntityLivingBase; -/* 6: */ import net.minecraft.item.ItemStack; -/* 7: */ import net.minecraft.nbt.NBTTagCompound; -/* 8: */ import net.minecraft.potion.PotionEffect; -/* 9: */ import net.minecraft.world.World; -/* 10: */ -/* 11: */ public class GT_Entity_Arrow_Potion -/* 12: */ extends GT_Entity_Arrow -/* 13: */ { -/* 14: */ public GT_Entity_Arrow_Potion(World aWorld) -/* 15: */ { -/* 16:13 */ super(aWorld); -/* 17: */ } -/* 18: */ -/* 19: */ public GT_Entity_Arrow_Potion(World aWorld, double aX, double aY, double aZ) -/* 20: */ { -/* 21:17 */ super(aWorld, aX, aY, aZ); -/* 22: */ } -/* 23: */ -/* 24: */ public GT_Entity_Arrow_Potion(World aWorld, EntityLivingBase aEntity, float aSpeed) -/* 25: */ { -/* 26:21 */ super(aWorld, aEntity, aSpeed); -/* 27: */ } -/* 28: */ -/* 29: */ public void writeEntityToNBT(NBTTagCompound aNBT) -/* 30: */ { -/* 31:26 */ super.writeEntityToNBT(aNBT); -/* 32:27 */ aNBT.setIntArray("mPotions", this.mPotions); -/* 33: */ } -/* 34: */ -/* 35: */ public void readEntityFromNBT(NBTTagCompound aNBT) -/* 36: */ { -/* 37:32 */ super.readEntityFromNBT(aNBT); -/* 38:33 */ setPotions(aNBT.getIntArray("mPotions")); -/* 39: */ } -/* 40: */ -/* 41: */ public boolean breaksOnImpact() -/* 42: */ { -/* 43:38 */ return true; -/* 44: */ } -/* 45: */ -/* 46: */ public void setPotions(int... aPotions) -/* 47: */ { -/* 48:49 */ if (aPotions != null) { -/* 49:49 */ this.mPotions = aPotions; -/* 50: */ } -/* 51: */ } -/* 52: */ -/* 53: */ public int[] getPotions() -/* 54: */ { -/* 55:53 */ return this.mPotions; -/* 56: */ } -/* 57: */ -/* 58:56 */ private int[] mPotions = new int[0]; -/* 59: */ -/* 60: */ public int[] onHitEntity(Entity aHitEntity, Entity aShootingEntity, ItemStack aArrow, int aRegularDamage, int aMagicDamage, int aKnockback, int aFireDamage, int aHitTimer) -/* 61: */ { -/* 62:60 */ if ((aHitEntity instanceof EntityLivingBase)) { -/* 63:60 */ for (int i = 3; i < this.mPotions.length; i += 4) { -/* 64:61 */ if (aHitEntity.worldObj.rand.nextInt(100) < this.mPotions[i]) { -/* 65:62 */ ((EntityLivingBase)aHitEntity).addPotionEffect(new PotionEffect(this.mPotions[(i - 3)], this.mPotions[(i - 2)], this.mPotions[(i - 1)], false)); -/* 66: */ } -/* 67: */ } -/* 68: */ } -/* 69:65 */ return super.onHitEntity(aHitEntity, aShootingEntity, aArrow, 1, aMagicDamage, aKnockback, aFireDamage, aHitTimer); -/* 70: */ } -/* 71: */ } +package gregtech.common.entities; + +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; + +public class GT_Entity_Arrow_Potion + extends GT_Entity_Arrow +{ + public GT_Entity_Arrow_Potion(World aWorld) + { + super(aWorld); + } + + public GT_Entity_Arrow_Potion(World aWorld, double aX, double aY, double aZ) + { + super(aWorld, aX, aY, aZ); + } + + public GT_Entity_Arrow_Potion(World aWorld, EntityLivingBase aEntity, float aSpeed) + { + super(aWorld, aEntity, aSpeed); + } + + public void writeEntityToNBT(NBTTagCompound aNBT) + { + super.writeEntityToNBT(aNBT); + aNBT.setIntArray("mPotions", this.mPotions); + } + + public void readEntityFromNBT(NBTTagCompound aNBT) + { + super.readEntityFromNBT(aNBT); + setPotions(aNBT.getIntArray("mPotions")); + } + + public boolean breaksOnImpact() + { + return true; + } + + public void setPotions(int... aPotions) + { + if (aPotions != null) { + this.mPotions = aPotions; + } + } + + public int[] getPotions() + { + return this.mPotions; + } + + private int[] mPotions = new int[0]; + + public int[] onHitEntity(Entity aHitEntity, Entity aShootingEntity, ItemStack aArrow, int aRegularDamage, int aMagicDamage, int aKnockback, int aFireDamage, int aHitTimer) + { + if ((aHitEntity instanceof EntityLivingBase)) { + for (int i = 3; i < this.mPotions.length; i += 4) { + if (aHitEntity.worldObj.rand.nextInt(100) < this.mPotions[i]) { + ((EntityLivingBase)aHitEntity).addPotionEffect(new PotionEffect(this.mPotions[(i - 3)], this.mPotions[(i - 2)], this.mPotions[(i - 1)], false)); + } + } + } + return super.onHitEntity(aHitEntity, aShootingEntity, aArrow, 1, aMagicDamage, aKnockback, aFireDamage, aHitTimer); + } +} /* Location: F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar -- cgit