private DamageSource getFlamethrowerDamage() { if (owner == null) { return DamageSource.causeThrownDamage(this, this); } else { return DamageSource.causeThrownDamage(this, owner); } }
/** Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { /*if (par1MovingObjectPosition.entityHit != null) { byte b0 = 0; if (par1MovingObjectPosition.entityHit instanceof EntityBlaze) { b0 = 0; } par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); } for (int i = 0; i < 0; ++i) { this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if (!this.worldObj.isRemote) { this.setDead(); }*/ if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), valueDamage); } if (!this.worldObj.isRemote) { this.setDead(); } }
protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { int i0 = StuffWorthThrowingConfig.rockMinDamage; int i1 = StuffWorthThrowingConfig.rockMaxDamage - i0 + 1; int i2 = this.rand.nextInt(i1) + i0 + StuffWorthThrowingConfig.brokenBrickStronger; int i3 = StuffWorthThrowingConfig.dizzyMultiplier; int i4 = StuffWorthThrowingConfig.debuffMultiplier; if (!this.worldObj.isRemote && StuffWorthThrowingConfig.itemStatusEffects) { EntityLivingBase entityLiving = (EntityLivingBase) par1MovingObjectPosition.entityHit; entityLiving.setFire(i2 * i4 / 20); if (StuffWorthThrowingConfig.dizzyBricks) { entityLiving.addPotionEffect(new PotionEffect(Potion.confusion.getId(), i2 * i3, 0)); } } par1MovingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), (byte) i2); } for (int i = 0; i < 8; ++i) { this.worldObj.spawnParticle("smoke", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if (!this.worldObj.isRemote) { this.setDead(); } }
@Override protected void onImpact(@Nonnull RayTraceResult pos) { if (isReturning()) return; switch (pos.typeOfHit) { case BLOCK: { Block block = worldObj.getBlockState(pos.getBlockPos()).getBlock(); if (block instanceof BlockBush || block instanceof BlockLeaves) return; int bounces = getTimesBounced(); if (bounces < MAX_BOUNCES) { Vector3 currentMovementVec = new Vector3(motionX, motionY, motionZ); EnumFacing dir = pos.sideHit; Vector3 normalVector = new Vector3(dir.getFrontOffsetX(), dir.getFrontOffsetY(), dir.getFrontOffsetZ()) .normalize(); Vector3 movementVec = normalVector .multiply(-2 * currentMovementVec.dotProduct(normalVector)) .add(currentMovementVec); motionX = movementVec.x; motionY = movementVec.y; motionZ = movementVec.z; bounced = true; if (!worldObj.isRemote) setTimesBounced(getTimesBounced() + 1); } break; } case ENTITY: { if (!worldObj.isRemote && pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != getThrower()) { EntityLivingBase thrower = getThrower(); pos.entityHit.attackEntityFrom( thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causeThrownDamage(this, thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.generic, 12); if (isFire()) pos.entityHit.setFire(5); else if (worldObj.rand.nextInt(3) == 0) ((EntityLivingBase) pos.entityHit) .addPotionEffect(new PotionEffect(MobEffects.POISON, 60, 0)); } break; } } }
protected void onImpact(MovingObjectPosition var1) { if (var1.entityHit != null) { var1.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.thrower), this.damage); } if (!this.worldObj.isRemote) { this.setDead(); } }
@Override protected void onImpact(MovingObjectPosition pos) { if (pos.entityHit != null && pos.entityHit instanceof EntityPlayer) { pos.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.thrower), (float) EntityStats.mandragoraDamage); } if (!this.worldObj.isRemote) { this.setDead(); } }
/** Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition var1) { int var2 = this.worldObj.getBlockId(var1.blockX, var1.blockY, var1.blockZ); int var3 = this.worldObj.getBlockMetadata(var1.blockX, var1.blockY, var1.blockZ); int x = var1.blockX; int y = var1.blockY; int z = var1.blockZ; if (status == 0) { // if (world.getBlockMaterial(x, y, z)== Material.water && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.ice.blockID); // } // if (world.getBlockMaterial(x, y, z )== Material.lava && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.stone.blockID); // } if (world.getBlockMaterial(x, y + 1, z) == Material.air && world.getBlockMaterial(x, y, z) != Material.snow && world.getBlockMaterial(x, y, z) != Material.ice) { world.setBlock(x, y + 1, z, Block.snow.blockID); } } else if (status == 1) { // if (world.getBlockMaterial(x, y, z )== Material.rock && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.lavaStill.blockID); // } if (world.getBlockMaterial(x, y, z) == Material.ice && world.getBlockMetadata(x, y, z) == 0) { world.setBlockToAir(x, y, z); world.setBlock(x, y, z, Block.waterStill.blockID); } if (world.getBlockMaterial(x, y, z) == Material.snow && world.getBlockMetadata(x, y, z) == 0) { world.setBlockToAir(x, y, z); } } if (var1.entityHit != null) { var1.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), damage); if (status == 1) { var1.entityHit.setFire(20); } else if (status == 0 && var1.entityHit instanceof EntityLiving) { ((EntityLiving) var1.entityHit) .addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 2)); } } if (!this.worldObj.isRemote) { this.setDead(); } }
@SuppressWarnings("unchecked") @Override protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (isExplode) { this.explodeSize = 3.0F; } if (isNuke) { this.explodeSize = 35.0F; } if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), 2); par1MovingObjectPosition.entityHit.setFire(5); } if (!this.worldObj.isRemote && !isNuke) { this.worldObj.newExplosion( (Entity) null, this.posX, this.posY, this.posZ, explodeSize, onFire, true); this.isDead = true; } else if (!this.worldObj.isRemote && isNuke) { this.worldObj.newExplosion( (Entity) null, this.posX, this.posY, this.posZ, explodeSize, onFire, true); Iterator<EntityLiving> itr = this.worldObj .getEntitiesWithinAABB(EntityLiving.class, this.boundingBox.expand(30, 30, 30)) .iterator(); while (itr.hasNext()) { EntityLiving entity = itr.next(); double dx = Math.abs(entity.posX - this.posX); double dy = Math.abs(entity.posY - this.posY); double dz = Math.abs(entity.posZ - this.posZ); int distance = (int) Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2)); if (30 - distance >= 0) { entity.addPotionEffect( new PotionEffect(2, (60 + (30 - distance)) * 20, (30 - distance) / 5)); entity.addPotionEffect( new PotionEffect(4, (60 + (30 - distance)) * 20, (30 - distance) / 5)); entity.addPotionEffect( new PotionEffect(18, (60 + (30 - distance)) * 20, (30 - distance) / 5)); entity.addPotionEffect( new PotionEffect(19, (60 + (30 - distance)) * 20, (30 - distance) / 5)); } } this.isDead = true; } }
/** Called when this EntityThrowable hits a block or entity. */ @Override protected void onImpact(MovingObjectPosition var1) { if (var1.entityHit != null) { byte var2 = 24; if (var1.entityHit instanceof EntityBlaze) { var2 = 24; } var1.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), var2); } if (!this.worldObj.isRemote) { this.setDead(); } }
@Override protected void onImpact(MovingObjectPosition mop) { if (mop.entityHit != null) { mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 0.0F); } if (!this.worldObj.isRemote) { EntityThaumiumBoss entity = new EntityThaumiumBoss(this.worldObj); entity.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); this.worldObj.spawnEntityInWorld(entity); } for (int j = 0; j < 8; j++) { this.worldObj.spawnParticle( "snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if (!this.worldObj.isRemote) { setDead(); } }
/** Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition var1) { if (var1.entityHit != null) { byte var2 = 0; if (var1.entityHit instanceof EntityBlaze) { var2 = 3; } if (!var1.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), var2)) {; } } for (int var3 = 0; var3 < 8; ++var3) { this.worldObj.spawnParticle("none", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if (!this.worldObj.isRemote) { this.setDead(); if (!this.worldObj.isRemote) { this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 2.5F, true); } } }
@Override protected void onImpact(MovingObjectPosition mObjPos) { if (Side.SERVER == FMLCommonHandler.instance().getEffectiveSide()) { if (mObjPos.entityHit != null) { mObjPos.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), 0); } EntityChicobo babyChicobo = FactoryEntityChocobo.createNewChicobo(worldObj, chocoboColor.PURPLE); if (babyChicobo != null) { babyChicobo.setTimeUntilAdult( rand.nextInt(ModChocoCraft.growupDelayRandom) + ModChocoCraft.growupDelayStatic); babyChicobo.setGrowingAge(babyChicobo.getTimeUntilAdult()); babyChicobo.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); this.worldObj.spawnEntityInWorld(babyChicobo); for (int i = 0; i < 8; i++) { this.sendParticleUpdate("snowballpoof", babyChicobo, 7); } } this.setDead(); } }
/** Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { byte b0 = 0; int i0 = StuffWorthThrowingConfig.debuffMultiplier; if (!this.worldObj.isRemote && StuffWorthThrowingConfig.itemStatusEffects) { EntityLivingBase entityLiving = (EntityLivingBase) par1MovingObjectPosition.entityHit; entityLiving.addPotionEffect(new PotionEffect(Potion.blindness.getId(), 3 * i0, 0)); } par1MovingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), b0); } for (int i = 0; i < 8; ++i) { this.worldObj.spawnParticle("crit", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if (!this.worldObj.isRemote) { this.setDead(); } }
@Redirect( method = "onUpdate()V", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/Entity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z")) public boolean onAttackEntityFrom( net.minecraft.entity.Entity entity, DamageSource damageSource, float damage) { EntitySnapshot fishHookSnapshot = this.createSnapshot(); FishingEvent.HookEntity event = SpongeEventFactory.createFishingEventHookEntity( Cause.of(NamedCause.source(this.angler)), this.createSnapshot(), this, (Entity) entity); if (!SpongeImpl.postEvent(event)) { if (this.getShooter() instanceof Entity) { DamageSource.causeThrownDamage( (net.minecraft.entity.Entity) (Object) this, (net.minecraft.entity.Entity) this.getShooter()); } return entity.attackEntityFrom(damageSource, (float) this.getDamage()); } return false; }
/** Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); for (int i = 0; i < 15; i++) { double d = rand.nextGaussian() * 0.10000000000000001D; double d1 = rand.nextGaussian() * 0.10000000000000001D; double d2 = rand.nextGaussian() * 0.10000000000000001D; worldObj.spawnParticle( EnumParticleTypes.EXPLOSION_NORMAL, posX + (double) (rand.nextFloat() * 2.0F), posY, posZ + (double) (rand.nextFloat() * 2.0F), d, d1, d2); } if (aoLightValueScratchXYNN == 100) { setDead(); } if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI); prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI); } if (aoLightValueZPos) { Block j = worldObj.getBlockState(new BlockPos(hitX, hitY, hitZ)).getBlock(); if (j != blockHit) { aoLightValueZPos = false; motionX *= rand.nextFloat() * 0.2F; motionY *= rand.nextFloat() * 0.2F; motionZ *= rand.nextFloat() * 0.2F; aoLightValueScratchXYZNNP = 0; aoLightValueScratchXYNN = 0; } else { aoLightValueScratchXYZNNP++; if (aoLightValueScratchXYZNNP == 100) { setDead(); } return; } } else { aoLightValueScratchXYNN++; } Vec3 vec3d = new Vec3(posX, posY, posZ); Vec3 vec3d1 = new Vec3(posX + motionX, posY + motionY, posZ + motionZ); MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1); vec3d = new Vec3(posX, posY, posZ); vec3d1 = new Vec3(posX + motionX, posY + motionY, posZ + motionZ); if (movingobjectposition != null) { vec3d1 = new Vec3( movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = worldObj.getEntitiesWithinAABBExcludingEntity( this, getEntityBoundingBox().addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); double d3 = 0.0D; for (int k = 0; k < list.size(); k++) { Entity entity1 = (Entity) list.get(k); if (!entity1.canBeCollidedWith() || (entity1 == shootingEntity || shootingEntity != null && entity1 == shootingEntity.ridingEntity) && aoLightValueScratchXYNN < 5 || aoLightValueScratchXYZNNN) { if (motionZ != 0.0D || !((motionX == 0.0D) & (motionY == 0.0D))) { continue; } setDead(); break; } float f4 = 0.3F; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f4, f4, f4); MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1); if (movingobjectposition1 == null) { continue; } double d4 = vec3d.distanceTo(movingobjectposition1.hitVec); if (d4 < d3 || d3 == 0.0D) { entity = entity1; d3 = d4; } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (movingobjectposition.entityHit instanceof EntityLivingBase) { splash(); movingobjectposition.entityHit.setFire(0); if (movingobjectposition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, (EntityLiving) entity), 0)) ; setDead(); } else { setDead(); } } else { hitX = movingobjectposition.getBlockPos().getX(); hitY = movingobjectposition.getBlockPos().getY(); hitZ = movingobjectposition.getBlockPos().getZ(); blockHit = worldObj.getBlockState(new BlockPos(hitX, hitY, hitZ)).getBlock(); motionX = (float) (movingobjectposition.hitVec.xCoord - posX); motionY = (float) (movingobjectposition.hitVec.yCoord - posY); motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ); float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ); posX -= (motionX / (double) f1) * 0.05000000074505806D; posY -= (motionY / (double) f1) * 0.05000000074505806D; posZ -= (motionZ / (double) f1) * 0.05000000074505806D; aoLightValueZPos = true; for (int l = -2; l < 2; l++) { for (int i1 = -2; i1 < 2; i1++) { for (int j1 = -2; j1 < 2; j1++) { if (worldObj.getBlockState(new BlockPos(hitX + l, hitY + j1, hitZ + i1)).getBlock() == Blocks.fire) { worldObj.setBlockToAir(new BlockPos(hitX + l, hitY + j1, hitZ + i1)); } } } } setDead(); } worldObj.playSoundAtEntity( this, "morecreeps:raygun", 0.2F, 1.0F / (rand.nextFloat() * 0.1F + 0.95F)); setDead(); } posX += motionX; posY += motionY; posZ += motionZ; float f2 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI); for (rotationPitch = (float) ((Math.atan2(motionY, f2) * 180D) / Math.PI); 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 f3 = 0.99F; float f5 = 0.0F; if (handleWaterMovement()) { for (int k1 = 0; k1 < 4; k1++) { float f7 = 0.25F; worldObj.spawnParticle( EnumParticleTypes.WATER_BUBBLE, posX - motionX * (double) f7, posY - motionY * (double) f7, posZ - motionZ * (double) f7, motionX, motionY, motionZ); } f3 = 0.8F; float f6 = 0.03F; setDead(); } motionX *= f3; motionZ *= f3; setPosition(posX, posY, posZ); }
/** Called to update the entity's position/logic. */ public void onUpdate() { this.onEntityUpdate(); if (this.fishPosRotationIncrements > 0) { double var21 = this.posX + (this.fishX - this.posX) / this.fishPosRotationIncrements; double var22 = this.posY + (this.fishY - this.posY) / this.fishPosRotationIncrements; double var23 = this.posZ + (this.fishZ - this.posZ) / this.fishPosRotationIncrements; double var7 = MathHelper.wrapAngleTo180_double(this.fishYaw - this.rotationYaw); this.rotationYaw = (float) (this.rotationYaw + var7 / this.fishPosRotationIncrements); this.rotationPitch = (float) (this.rotationPitch + (this.fishPitch - this.rotationPitch) / this.fishPosRotationIncrements); --this.fishPosRotationIncrements; this.setPosition(var21, var22, var23); this.setRotation(this.rotationYaw, this.rotationPitch); } else { if (!this.worldObj.isRemote) { if (angler != null) { ItemStack itemStack = this.angler.getHeldItem(); if (this.angler.isDead || !this.angler.isEntityAlive() || itemStack == null || itemStack.getItem() != Item.fishingRod || this.getDistanceSqToEntity(this.angler) > 1024.0D) { this.setDead(); this.angler.fishingChore.fishEntity = null; return; } } else { this.setDead(); } if (this.bobber != null) { if (!this.bobber.isDead) { this.posX = this.bobber.posX; this.posY = this.bobber.boundingBox.minY + this.bobber.height * 0.8D; this.posZ = this.bobber.posZ; return; } this.bobber = null; } if (this != null) { if (this.isDead && this.bobber != null) { this.bobber.setDead(); } } } if (this.shake > 0) { --this.shake; } if (this.inGround) { int blockId = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); if (blockId == this.inTile) { ++this.ticksInGround; if (this.ticksInGround >= 20) { this.setDead(); try { angler.fishingChore.fishEntity = null; } catch (NullPointerException e) { return; } } return; } 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.ticksInGround = 0; this.ticksInAir = 0; } else { ++this.ticksInAir; } Vec3 vector = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); Vec3 motionVector = this.worldObj .getWorldVec3Pool() .getVecFromPool( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingObjectPosition = this.worldObj.clip(vector, motionVector); vector = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); motionVector = this.worldObj .getWorldVec3Pool() .getVecFromPool( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingObjectPosition != null) { motionVector = this.worldObj .getWorldVec3Pool() .getVecFromPool( movingObjectPosition.hitVec.xCoord, movingObjectPosition.hitVec.yCoord, movingObjectPosition.hitVec.zCoord); } Entity entity = null; List entityList = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.boundingBox .addCoord(this.motionX, this.motionY, this.motionZ) .expand(1.0D, 1.0D, 1.0D)); double zeroDistance = 0.0D; double vectorDistance; for (int i = 0; i < entityList.size(); ++i) { Entity entityInList = (Entity) entityList.get(i); if (entityInList.canBeCollidedWith() && (entityInList != this.angler || this.ticksInAir >= 5)) { float boundingBoxExpansion = 0.3F; AxisAlignedBB bb = entityInList.boundingBox.expand( boundingBoxExpansion, boundingBoxExpansion, boundingBoxExpansion); MovingObjectPosition interceptPosition = bb.calculateIntercept(vector, motionVector); if (interceptPosition != null) { vectorDistance = vector.distanceTo(interceptPosition.hitVec); if (vectorDistance < zeroDistance || zeroDistance == 0.0D) { entity = entityInList; zeroDistance = vectorDistance; } } } } if (entity != null) { movingObjectPosition = new MovingObjectPosition(entity); } if (movingObjectPosition != null) { if (movingObjectPosition.entityHit != null) { if (movingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.angler), 0)) { this.bobber = movingObjectPosition.entityHit; } } else { this.inGround = true; } } if (!this.inGround) { this.moveEntity(this.motionX, this.motionY, this.motionZ); float motion = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float) (Math.atan2(this.motionY, motion) * 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; } 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 motionModifier = 0.92F; if (this.onGround || this.isCollidedHorizontally) { motionModifier = 0.5F; } byte endByte = 5; double yMotion = 0.0D; for (int i = 0; i < endByte; ++i) { double boundingBoxMinY = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (i + 0) / endByte - 0.125D + 0.125D; double boundingBoxMaxY = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (i + 1) / endByte - 0.125D + 0.125D; AxisAlignedBB bb = AxisAlignedBB.getAABBPool() .getAABB( this.boundingBox.minX, boundingBoxMinY, this.boundingBox.minZ, this.boundingBox.maxX, boundingBoxMaxY, this.boundingBox.maxZ); if (this.worldObj.isAABBInMaterial(bb, Material.water)) { yMotion += 1.0D / endByte; } } if (yMotion > 0.0D) { if (this.ticksCatchable > 0) { --this.ticksCatchable; } else { short fishCatchChance = 500; if (this.worldObj.canLightningStrikeAt( MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1, MathHelper.floor_double(this.posZ))) { fishCatchChance = 300; } if (this.rand.nextInt(fishCatchChance) == 0) { this.ticksCatchable = this.rand.nextInt(30) + 10; this.motionY -= 0.20000000298023224D; this.playSound( "random.splash", 0.25F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); float floorMinY = MathHelper.floor_double(this.boundingBox.minY); int i; float randomFloat1; float randomFloat2; for (i = 0; i < 1.0F + this.width * 20.0F; ++i) { randomFloat1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; randomFloat2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; this.worldObj.spawnParticle( "bubble", this.posX + randomFloat1, floorMinY + 1.0F, this.posZ + randomFloat2, this.motionX, this.motionY - this.rand.nextFloat() * 0.2F, this.motionZ); } for (i = 0; i < 1.0F + this.width * 20.0F; ++i) { randomFloat1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; randomFloat2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; this.worldObj.spawnParticle( "splash", this.posX + randomFloat1, floorMinY + 1.0F, this.posZ + randomFloat2, this.motionX, this.motionY, this.motionZ); } } } } if (this.ticksCatchable > 0) { this.motionY -= this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat() * 0.2D; } vectorDistance = yMotion * 2.0D - 1.0D; this.motionY += 0.03999999910593033D * vectorDistance; if (yMotion > 0.0D) { motionModifier = (float) (motionModifier * 0.9D); this.motionY *= 0.8D; } this.motionX *= motionModifier; this.motionY *= motionModifier; this.motionZ *= motionModifier; this.setPosition(this.posX, this.posY, this.posZ); } } try { if (this.angler.fishingChore.hasEnded) { this.setDead(); } } catch (NullPointerException e) { return; } }
/** Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (aoLightValueScratchXYNN == 100) { setDead(); } if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI); prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI); } if (aoLightValueZPos) { Block i = worldObj.getBlockState(new BlockPos(hitX, hitY, hitZ)).getBlock(); if (i != blockHit) { aoLightValueZPos = false; motionX *= rand.nextFloat() * 0.2F; motionY *= rand.nextFloat() * 0.2F; motionZ *= rand.nextFloat() * 0.2F; aoLightValueScratchXYZNNP = 0; aoLightValueScratchXYNN = 0; } else { aoLightValueScratchXYZNNP++; if (aoLightValueScratchXYZNNP == 100) { setDead(); } return; } } else { aoLightValueScratchXYNN++; } Vec3 vec3d = new Vec3(posX, posY, posZ); Vec3 vec3d1 = new Vec3(posX + motionX, posY + motionY, posZ + motionZ); MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1); vec3d = new Vec3(posX, posY, posZ); vec3d1 = new Vec3(posX + motionX, posY + motionY, posZ + motionZ); if (movingobjectposition != null) { vec3d1 = new Vec3( movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = worldObj.getEntitiesWithinAABBExcludingEntity( this, getEntityBoundingBox().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 == shootingEntity || shootingEntity != null && entity1 == shootingEntity.ridingEntity) && aoLightValueScratchXYNN < 5 || aoLightValueScratchXYZNNN) { if (motionZ != 0.0D || !((motionX == 0.0D) & (motionY == 0.0D))) { continue; } setDead(); break; } float f4 = 0.3F; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f4, f4, f4); 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); } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (movingobjectposition.entityHit instanceof EntityPlayer) { int k = damage; if (worldObj.getDifficulty() == EnumDifficulty.PEACEFUL) { k = 0; } if (worldObj.getDifficulty() == EnumDifficulty.EASY) { k = k / 3 + 1; } if (worldObj.getDifficulty() == EnumDifficulty.HARD) { k = (k * 3) / 2; } } if ((movingobjectposition.entityHit instanceof EntityLiving) && playerFire || !(movingobjectposition.entityHit instanceof CREEPSEntityFloob) || playerFire) { if (movingobjectposition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, shootingEntity), damage)) ; setDead(); } else { setDead(); } } else { hitX = movingobjectposition.getBlockPos().getX(); hitY = movingobjectposition.getBlockPos().getY(); hitZ = movingobjectposition.getBlockPos().getZ(); blockHit = worldObj.getBlockState(new BlockPos(hitX, hitY, hitZ)); motionX = (float) (movingobjectposition.hitVec.xCoord - posX); motionY = (float) (movingobjectposition.hitVec.yCoord - posY); motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ); float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ); posX -= (motionX / (double) f1) * 0.05000000074505806D; posY -= (motionY / (double) f1) * 0.05000000074505806D; posZ -= (motionZ / (double) f1) * 0.05000000074505806D; aoLightValueZPos = true; setDead(); if (CREEPSConfig.rayGunMelt && rand.nextInt(5) == 0 && worldObj.getBlockState(new BlockPos(hitX, hitY, hitZ)).getBlock() != Blocks.bedrock) { if (CREEPSConfig.rayGunFire) { worldObj.setBlockState(new BlockPos(hitX, hitY, hitZ), Blocks.fire.getDefaultState()); } else { worldObj.setBlockToAir(new BlockPos(hitX, hitY, hitZ)); } } if (blockHit == Blocks.ice.getDefaultState()) { worldObj.setBlockState( new BlockPos(hitX, hitY, hitZ), Blocks.flowing_water.getDefaultState()); } if (CREEPSConfig.rayGunFire && blockHit == Blocks.glass.getDefaultState()) { Side side = FMLCommonHandler.instance().getSide(); worldObj.setBlockToAir(new BlockPos(hitX, hitY, hitZ)); if (side == Side.CLIENT) { FMLClientHandler.instance() .getClient() .effectRenderer .func_180533_a(new BlockPos(hitX, hitY, hitZ), Blocks.glass.getDefaultState()); } } setDead(); } worldObj.playSoundAtEntity( this, "morecreeps:raygun", 0.2F, 1.0F / (rand.nextFloat() * 0.1F + 0.95F)); setDead(); } posX += motionX; posY += motionY; posZ += motionZ; float f2 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI); for (rotationPitch = (float) ((Math.atan2(motionY, f2) * 180D) / Math.PI); 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 f3 = 0.99F; float f5 = 0.0F; if (handleWaterMovement()) { for (int l = 0; l < 4; l++) { float f7 = 0.25F; worldObj.spawnParticle( EnumParticleTypes.WATER_BUBBLE, posX - motionX * (double) f7, posY - motionY * (double) f7, posZ - motionZ * (double) f7, motionX, motionY, motionZ, new int[0]); } f3 = 0.8F; float f6 = 0.03F; setDead(); } motionX *= f3; motionZ *= f3; setPosition(posX, posY, posZ); }
public void damageType(MovingObjectPosition movObjPos) { movObjPos.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, getThrower()), this.damage); }
/** Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); 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); this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); } int i = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); if (i > 0) { Block.blocksList[i].setBlockBoundsBasedOnState( this.worldObj, this.xTile, this.yTile, this.zTile); AxisAlignedBB axisalignedbb = Block.blocksList[i].getCollisionBoundingBoxFromPool( this.worldObj, this.xTile, this.yTile, this.zTile); if (axisalignedbb != null && axisalignedbb.isVecInside( this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) { this.inGround = true; } } if (this.arrowShake > 0) { --this.arrowShake; } if (this.inGround) { int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); if (j == this.inTile && k == this.inData) { ++this.ticksInGround; if (this.ticksInGround == 20000) { this.setDead(); } } else { this.inGround = false; this.motionX *= (double) (this.rand.nextFloat() * 0.2F); this.motionY *= (double) (this.rand.nextFloat() * 0.2F); this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } } else { ++this.ticksInAir; Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); Vec3 vec31 = this.worldObj .getWorldVec3Pool() .getVecFromPool( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true); vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); vec31 = this.worldObj .getWorldVec3Pool() .getVecFromPool( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec31 = this.worldObj .getWorldVec3Pool() .getVecFromPool( movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.boundingBox .addCoord(this.motionX, this.motionY, this.motionZ) .expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; int l; float f1; for (l = 0; l < list.size(); ++l) { Entity entity1 = (Entity) list.get(l); if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) f1, (double) f1, (double) f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31); if (movingobjectposition1 != null) { double d1 = vec3.distanceTo(movingobjectposition1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).func_96122_a(entityplayer)) { movingobjectposition = null; } } float f2; float f3; if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { f2 = MathHelper.sqrt_double( this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); int i1 = MathHelper.ceiling_double_int((double) f2 * this.damage); if (this.getIsCritical()) { i1 += this.rand.nextInt(i1 / 2 + 2); } DamageSource damagesource = null; if (this.shootingEntity == null) { damagesource = DamageSource.causeThrownDamage(this, this); } else { damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity); } if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { movingobjectposition.entityHit.setFire(5); } if (Math.random() > 0.5) worldObj.addWeatherEffect( new EntityLightningBolt(worldObj, (double) posX, (double) posY, (double) posZ)); if (movingobjectposition.entityHit.attackEntityFrom(damagesource, i1)) { if (movingobjectposition.entityHit instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) movingobjectposition.entityHit; if (this.knockbackStrength > 0) { f3 = MathHelper.sqrt_double( this.motionX * this.motionX + this.motionZ * this.motionZ); if (f3 > 0.0F) { movingobjectposition.entityHit.addVelocity( this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3, 0.1D, this.motionZ * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3); } } if (this.shootingEntity != null) { EnchantmentThorns.func_92096_a(this.shootingEntity, entityliving, this.rand); } if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { ((EntityPlayerMP) this.shootingEntity) .playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0)); } } this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); } else { this.motionX *= -0.10000000149011612D; this.motionY *= -0.10000000149011612D; this.motionZ *= -0.10000000149011612D; this.rotationYaw += 180.0F; this.prevRotationYaw += 180.0F; this.ticksInAir = 0; } } else { this.xTile = movingobjectposition.blockX; this.yTile = movingobjectposition.blockY; this.zTile = movingobjectposition.blockZ; this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX)); this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY)); this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); f2 = MathHelper.sqrt_double( this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / (double) f2 * 0.05000000074505806D; this.posY -= this.motionY / (double) f2 * 0.05000000074505806D; this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D; this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.arrowShake = 7; this.setIsCritical(false); if (this.inTile != 0) { Block.blocksList[this.inTile].onEntityCollidedWithBlock( this.worldObj, this.xTile, this.yTile, this.zTile, this); } } } if (this.getIsCritical()) { for (l = 0; l < 4; ++l) { this.worldObj.spawnParticle( "crit", this.posX + this.motionX * (double) l / 4.0D, this.posY + this.motionY * (double) l / 4.0D, this.posZ + this.motionZ * (double) l / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); } } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f2) * 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; } 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 f4 = 0.99F; f1 = 0.05F; if (this.isInWater()) { for (int j1 = 0; j1 < 4; ++j1) { f3 = 0.25F; this.worldObj.spawnParticle( "bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, this.motionY, this.motionZ); } f4 = 0.45F; } this.motionX *= (double) f4; this.motionY *= (double) f4; this.motionZ *= (double) f4; this.motionY -= (double) f1; this.setPosition(this.posX, this.posY, this.posZ); this.doBlockCollisions(); } }
/** Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (this.fishPosRotationIncrements > 0) { double d7 = this.posX + (this.fishX - this.posX) / (double) this.fishPosRotationIncrements; double d8 = this.posY + (this.fishY - this.posY) / (double) this.fishPosRotationIncrements; double d9 = this.posZ + (this.fishZ - this.posZ) / (double) this.fishPosRotationIncrements; double d1 = MathHelper.wrapAngleTo180_double(this.fishYaw - (double) this.rotationYaw); this.rotationYaw = (float) ((double) this.rotationYaw + d1 / (double) this.fishPosRotationIncrements); this.rotationPitch = (float) ((double) this.rotationPitch + (this.fishPitch - (double) this.rotationPitch) / (double) this.fishPosRotationIncrements); --this.fishPosRotationIncrements; this.setPosition(d7, d8, d9); this.setRotation(this.rotationYaw, this.rotationPitch); } else { if (!this.worldObj.isRemote) { ItemStack itemstack = this.angler.getCurrentEquippedItem(); if (this.angler.isDead || !this.angler.isEntityAlive() || itemstack == null || itemstack.getItem() != Items.fishing_rod || this.getDistanceSqToEntity(this.angler) > 1024.0D) { this.setDead(); this.angler.fishEntity = null; return; } if (this.caughtEntity != null) { if (!this.caughtEntity.isDead) { this.posX = this.caughtEntity.posX; double d17 = (double) this.caughtEntity.height; this.posY = this.caughtEntity.getEntityBoundingBox().minY + d17 * 0.8D; this.posZ = this.caughtEntity.posZ; return; } this.caughtEntity = null; } } if (this.shake > 0) { --this.shake; } if (this.inGround) { if (this.worldObj.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile) { ++this.ticksInGround; if (this.ticksInGround == 1200) { this.setDead(); } return; } this.inGround = false; this.motionX *= (double) (this.rand.nextFloat() * 0.2F); this.motionY *= (double) (this.rand.nextFloat() * 0.2F); this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } else { ++this.ticksInAir; } Vec3 vec31 = new Vec3(this.posX, this.posY, this.posZ); Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3); vec31 = new Vec3(this.posX, this.posY, this.posZ); vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec3 = new Vec3( movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.getEntityBoundingBox() .addCoord(this.motionX, this.motionY, this.motionZ) .expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; for (int i = 0; i < list.size(); ++i) { Entity entity1 = (Entity) list.get(i); if (entity1.canBeCollidedWith() && (entity1 != this.angler || this.ticksInAir >= 5)) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double) f, (double) f, (double) f); MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec31, vec3); if (movingobjectposition1 != null) { double d2 = vec31.squareDistanceTo(movingobjectposition1.hitVec); if (d2 < d0 || d0 == 0.0D) { entity = entity1; d0 = d2; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (movingobjectposition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.angler), 0.0F)) { this.caughtEntity = movingobjectposition.entityHit; } } else { this.inGround = true; } } if (!this.inGround) { this.moveEntity(this.motionX, this.motionY, this.motionZ); float f5 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float) (MathHelper.func_181159_b(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float) (MathHelper.func_181159_b(this.motionY, (double) f5) * 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; } 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 f6 = 0.92F; if (this.onGround || this.isCollidedHorizontally) { f6 = 0.5F; } int j = 5; double d10 = 0.0D; for (int k = 0; k < j; ++k) { AxisAlignedBB axisalignedbb1 = this.getEntityBoundingBox(); double d3 = axisalignedbb1.maxY - axisalignedbb1.minY; double d4 = axisalignedbb1.minY + d3 * (double) k / (double) j; double d5 = axisalignedbb1.minY + d3 * (double) (k + 1) / (double) j; AxisAlignedBB axisalignedbb2 = new AxisAlignedBB( axisalignedbb1.minX, d4, axisalignedbb1.minZ, axisalignedbb1.maxX, d5, axisalignedbb1.maxZ); if (this.worldObj.isAABBInMaterial(axisalignedbb2, Material.water)) { d10 += 1.0D / (double) j; } } if (!this.worldObj.isRemote && d10 > 0.0D) { WorldServer worldserver = (WorldServer) this.worldObj; int l = 1; BlockPos blockpos = (new BlockPos(this)).up(); if (this.rand.nextFloat() < 0.25F && this.worldObj.canLightningStrike(blockpos)) { l = 2; } if (this.rand.nextFloat() < 0.5F && !this.worldObj.canSeeSky(blockpos)) { --l; } if (this.ticksCatchable > 0) { --this.ticksCatchable; if (this.ticksCatchable <= 0) { this.ticksCaughtDelay = 0; this.ticksCatchableDelay = 0; } } else if (this.ticksCatchableDelay > 0) { this.ticksCatchableDelay -= l; if (this.ticksCatchableDelay <= 0) { this.motionY -= 0.20000000298023224D; this.playSound( "random.splash", 0.25F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); float f8 = (float) MathHelper.floor_double(this.getEntityBoundingBox().minY); worldserver.spawnParticle( EnumParticleTypes.WATER_BUBBLE, this.posX, (double) (f8 + 1.0F), this.posZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D, new int[0]); worldserver.spawnParticle( EnumParticleTypes.WATER_WAKE, this.posX, (double) (f8 + 1.0F), this.posZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D, new int[0]); this.ticksCatchable = MathHelper.getRandomIntegerInRange(this.rand, 10, 30); } else { this.fishApproachAngle = (float) ((double) this.fishApproachAngle + this.rand.nextGaussian() * 4.0D); float f7 = this.fishApproachAngle * 0.017453292F; float f10 = MathHelper.sin(f7); float f11 = MathHelper.cos(f7); double d13 = this.posX + (double) (f10 * (float) this.ticksCatchableDelay * 0.1F); double d15 = (double) ((float) MathHelper.floor_double(this.getEntityBoundingBox().minY) + 1.0F); double d16 = this.posZ + (double) (f11 * (float) this.ticksCatchableDelay * 0.1F); Block block1 = worldserver .getBlockState(new BlockPos((int) d13, (int) d15 - 1, (int) d16)) .getBlock(); if (block1 == Blocks.water || block1 == Blocks.flowing_water) { if (this.rand.nextFloat() < 0.15F) { worldserver.spawnParticle( EnumParticleTypes.WATER_BUBBLE, d13, d15 - 0.10000000149011612D, d16, 1, (double) f10, 0.1D, (double) f11, 0.0D, new int[0]); } float f3 = f10 * 0.04F; float f4 = f11 * 0.04F; worldserver.spawnParticle( EnumParticleTypes.WATER_WAKE, d13, d15, d16, 0, (double) f4, 0.01D, (double) (-f3), 1.0D, new int[0]); worldserver.spawnParticle( EnumParticleTypes.WATER_WAKE, d13, d15, d16, 0, (double) (-f4), 0.01D, (double) f3, 1.0D, new int[0]); } } } else if (this.ticksCaughtDelay > 0) { this.ticksCaughtDelay -= l; float f1 = 0.15F; if (this.ticksCaughtDelay < 20) { f1 = (float) ((double) f1 + (double) (20 - this.ticksCaughtDelay) * 0.05D); } else if (this.ticksCaughtDelay < 40) { f1 = (float) ((double) f1 + (double) (40 - this.ticksCaughtDelay) * 0.02D); } else if (this.ticksCaughtDelay < 60) { f1 = (float) ((double) f1 + (double) (60 - this.ticksCaughtDelay) * 0.01D); } if (this.rand.nextFloat() < f1) { float f9 = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F) * 0.017453292F; float f2 = MathHelper.randomFloatClamp(this.rand, 25.0F, 60.0F); double d12 = this.posX + (double) (MathHelper.sin(f9) * f2 * 0.1F); double d14 = (double) ((float) MathHelper.floor_double(this.getEntityBoundingBox().minY) + 1.0F); double d6 = this.posZ + (double) (MathHelper.cos(f9) * f2 * 0.1F); Block block = worldserver .getBlockState(new BlockPos((int) d12, (int) d14 - 1, (int) d6)) .getBlock(); if (block == Blocks.water || block == Blocks.flowing_water) { worldserver.spawnParticle( EnumParticleTypes.WATER_SPLASH, d12, d14, d6, 2 + this.rand.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, new int[0]); } } if (this.ticksCaughtDelay <= 0) { this.fishApproachAngle = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F); this.ticksCatchableDelay = MathHelper.getRandomIntegerInRange(this.rand, 20, 80); } } else { this.ticksCaughtDelay = MathHelper.getRandomIntegerInRange(this.rand, 100, 900); this.ticksCaughtDelay -= EnchantmentHelper.getLureModifier(this.angler) * 20 * 5; } if (this.ticksCatchable > 0) { this.motionY -= (double) (this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat()) * 0.2D; } } double d11 = d10 * 2.0D - 1.0D; this.motionY += 0.03999999910593033D * d11; if (d10 > 0.0D) { f6 = (float) ((double) f6 * 0.9D); this.motionY *= 0.8D; } this.motionX *= (double) f6; this.motionY *= (double) f6; this.motionZ *= (double) f6; this.setPosition(this.posX, this.posY, this.posZ); } } }
/** Called to update the entity's position/logic. */ @Override public void onUpdate() { onEntityUpdate(); if (fishPosRotationIncrements > 0) { final double var21 = posX + (fishX - posX) / fishPosRotationIncrements; final double var22 = posY + (fishY - posY) / fishPosRotationIncrements; final double var23 = posZ + (fishZ - posZ) / fishPosRotationIncrements; final double var7 = MathHelper.wrapAngleTo180_double(fishYaw - rotationYaw); rotationYaw = (float) (rotationYaw + var7 / fishPosRotationIncrements); rotationPitch = (float) (rotationPitch + (fishPitch - rotationPitch) / fishPosRotationIncrements); --fishPosRotationIncrements; setPosition(var21, var22, var23); setRotation(rotationYaw, rotationPitch); } else { if (!worldObj.isRemote) { if (angler != null) { final ItemStack itemStack = angler.getHeldItem(); if (angler.isDead || !angler.isEntityAlive() || itemStack == null || itemStack.getItem() != Items.fishing_rod || getDistanceSqToEntity(angler) > 1024.0D) { setDead(); angler.fishingChore.fishEntity = null; return; } } else { setDead(); } if (field_146043_c != null) { if (!field_146043_c.isDead) { posX = field_146043_c.posX; posY = field_146043_c.boundingBox.minY + field_146043_c.height * 0.8D; posZ = field_146043_c.posZ; return; } field_146043_c = null; } if (this != null) { if (isDead && field_146043_c != null) { field_146043_c.setDead(); } } } if (field_146044_a > 0) { --field_146044_a; } // TODO // if (this.inGround) // { // if (this.worldObj.getBlock(this.field_146037_g, this.field_146048_h, // this.field_146050_i) == this.field_146046_j) // { // ++this.ticksInGround; // // if (this.ticksInGround >= 20) // { // this.setDead(); // // try // { // angler.fishingChore.fishEntity = null; // } // // catch (NullPointerException e) // { // return; // } // } // // return; // } // // 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.ticksInGround = 0; // this.ticksInAir = 0; // } // // else // { // ++this.ticksInAir; // } Vec3 vector = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); Vec3 motionVector = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); MovingObjectPosition movingObjectPosition = worldObj.rayTraceBlocks(vector, motionVector); vector = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); motionVector = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); if (movingObjectPosition != null) { motionVector = worldObj .getWorldVec3Pool() .getVecFromPool( movingObjectPosition.hitVec.xCoord, movingObjectPosition.hitVec.yCoord, movingObjectPosition.hitVec.zCoord); } Entity entity = null; final List entityList = worldObj.getEntitiesWithinAABBExcludingEntity( this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); double zeroDistance = 0.0D; double vectorDistance; for (int i = 0; i < entityList.size(); ++i) { final Entity entityInList = (Entity) entityList.get(i); if (entityInList.canBeCollidedWith() && (entityInList != angler || ticksInAir >= 5)) { final float boundingBoxExpansion = 0.3F; final AxisAlignedBB bb = entityInList.boundingBox.expand( boundingBoxExpansion, boundingBoxExpansion, boundingBoxExpansion); final MovingObjectPosition interceptPosition = bb.calculateIntercept(vector, motionVector); if (interceptPosition != null) { vectorDistance = vector.distanceTo(interceptPosition.hitVec); if (vectorDistance < zeroDistance || zeroDistance == 0.0D) { entity = entityInList; zeroDistance = vectorDistance; } } } } if (entity != null) { movingObjectPosition = new MovingObjectPosition(entity); } if (movingObjectPosition != null) { if (movingObjectPosition.entityHit != null) { if (movingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, angler), 0)) { field_146043_c = movingObjectPosition.entityHit; } } else { inGround = true; } } if (!inGround) { moveEntity(motionX, motionY, motionZ); final float motion = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); for (rotationPitch = (float) (Math.atan2(motionY, motion) * 180.0D / Math.PI); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F) {; } while (rotationPitch - prevRotationPitch >= 180.0F) { prevRotationPitch += 360.0F; } while (rotationYaw - prevRotationYaw < -180.0F) { prevRotationYaw -= 360.0F; } while (rotationYaw - prevRotationYaw >= 180.0F) { prevRotationYaw += 360.0F; } rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; float motionModifier = 0.92F; if (onGround || isCollidedHorizontally) { motionModifier = 0.5F; } final byte endByte = 5; double yMotion = 0.0D; for (int i = 0; i < endByte; ++i) { final double boundingBoxMinY = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * (i + 0) / endByte - 0.125D + 0.125D; final double boundingBoxMaxY = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * (i + 1) / endByte - 0.125D + 0.125D; final AxisAlignedBB bb = AxisAlignedBB.getAABBPool() .getAABB( boundingBox.minX, boundingBoxMinY, boundingBox.minZ, boundingBox.maxX, boundingBoxMaxY, boundingBox.maxZ); if (worldObj.isAABBInMaterial(bb, Material.water)) { yMotion += 1.0D / endByte; } } if (yMotion > 0.0D) { if (ticksCatchable > 0) { --ticksCatchable; } else { short fishCatchChance = 500; if (worldObj.canLightningStrikeAt( MathHelper.floor_double(posX), MathHelper.floor_double(posY) + 1, MathHelper.floor_double(posZ))) { fishCatchChance = 300; } if (rand.nextInt(fishCatchChance) == 0) { ticksCatchable = rand.nextInt(30) + 10; motionY -= 0.20000000298023224D; playSound( "random.splash", 0.25F, 1.0F + (rand.nextFloat() - rand.nextFloat()) * 0.4F); final float floorMinY = MathHelper.floor_double(boundingBox.minY); int i; float randomFloat1; float randomFloat2; for (i = 0; i < 1.0F + width * 20.0F; ++i) { randomFloat1 = (rand.nextFloat() * 2.0F - 1.0F) * width; randomFloat2 = (rand.nextFloat() * 2.0F - 1.0F) * width; worldObj.spawnParticle( "bubble", posX + randomFloat1, floorMinY + 1.0F, posZ + randomFloat2, motionX, motionY - rand.nextFloat() * 0.2F, motionZ); } for (i = 0; i < 1.0F + width * 20.0F; ++i) { randomFloat1 = (rand.nextFloat() * 2.0F - 1.0F) * width; randomFloat2 = (rand.nextFloat() * 2.0F - 1.0F) * width; worldObj.spawnParticle( "splash", posX + randomFloat1, floorMinY + 1.0F, posZ + randomFloat2, motionX, motionY, motionZ); } } } } if (ticksCatchable > 0) { motionY -= rand.nextFloat() * rand.nextFloat() * rand.nextFloat() * 0.2D; } vectorDistance = yMotion * 2.0D - 1.0D; motionY += 0.03999999910593033D * vectorDistance; if (yMotion > 0.0D) { motionModifier = (float) (motionModifier * 0.9D); motionY *= 0.8D; } motionX *= motionModifier; motionY *= motionModifier; motionZ *= motionModifier; setPosition(posX, posY, posZ); } } try { if (angler.fishingChore.hasEnded) { setDead(); } } catch (final NullPointerException e) { return; } }