/** Checks if the entity's current position is a valid location to spawn this entity. */ public boolean getCanSpawnHere() { if (this.worldObj.rand.nextInt(3) == 0) { return false; } else { if (this.worldObj.checkIfAABBIsClear(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).size() == 0 && !this.worldObj.isAnyLiquid(this.boundingBox)) { int var1 = MathHelper.floor_double(this.posX); int var2 = MathHelper.floor_double(this.boundingBox.minY); int var3 = MathHelper.floor_double(this.posZ); if (var2 < 63) { return false; } int var4 = this.worldObj.getBlockId(var1, var2 - 1, var3); if (var4 == Block.grass.blockID || var4 == Block.leaves.blockID) { return true; } } return false; } }
public static MovingObjectPosition getMovingObjectPositionFromPlayer( World world, EntityLivingBase living, boolean bool) { float f = 1.0F; float f1 = living.prevRotationPitch + (living.rotationPitch - living.prevRotationPitch) * f; float f2 = living.prevRotationYaw + (living.rotationYaw - living.prevRotationYaw) * f; double d0 = living.prevPosX + (living.posX - living.prevPosX) * (double) f; double d1 = living.prevPosY + (living.posY - living.prevPosY) * (double) f + (double) (world.isRemote ? living.getEyeHeight() - (living instanceof EntityPlayer ? ((EntityPlayer) living).getDefaultEyeHeight() : 0) : living .getEyeHeight()); // isRemote check to revert changes to ray trace position // due to adding the eye height clientside and player // yOffset differences double d2 = living.prevPosZ + (living.posZ - living.prevPosZ) * (double) f; Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); float f5 = -MathHelper.cos(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F); float f7 = f4 * f5; float f8 = f3 * f5; double d3 = 5.0D; if (living instanceof EntityPlayerMP) d3 = ((EntityPlayerMP) living).theItemInWorldManager.getBlockReachDistance(); Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); return world.func_147447_a(vec3, vec31, bool, !bool, false); }
/** * Called frequently so the entity can update its state every tick as required. For example, * zombies and skeletons use this to react to sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); if (this.attackTimer > 0) { --this.attackTimer; } if (this.holdRoseTick > 0) { --this.holdRoseTick; } if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D && this.rand.nextInt(5) == 0) { int var1 = MathHelper.floor_double(this.posX); int var2 = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double) this.yOffset); int var3 = MathHelper.floor_double(this.posZ); int var4 = this.worldObj.getBlockId(var1, var2, var3); if (var4 > 0) { this.worldObj.spawnParticle( "tilecrack_" + var4 + "_" + this.worldObj.getBlockMetadata(var1, var2, var3), this.posX + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width, 4.0D * ((double) this.rand.nextFloat() - 0.5D), 0.5D, ((double) this.rand.nextFloat() - 0.5D) * 4.0D); } } }
/** Gets the safe pathing Y position for the entity depending on if it can path swim or not */ private int getPathableYPos() { if (this.theEntity.isInWater() && this.canSwim) { int var1 = (int) this.theEntity.boundingBox.minY; int var2 = this.worldObj.getBlockId( MathHelper.floor_double(this.theEntity.posX), var1, MathHelper.floor_double(this.theEntity.posZ)); int var3 = 0; do { if (var2 != Block.waterMoving.blockID && var2 != Block.waterStill.blockID) { return var1; } ++var1; var2 = this.worldObj.getBlockId( MathHelper.floor_double(this.theEntity.posX), var1, MathHelper.floor_double(this.theEntity.posZ)); ++var3; } while (var3 <= 16); return (int) this.theEntity.boundingBox.minY; } else { return (int) (this.theEntity.boundingBox.minY + 0.5D); } }
@Override protected void executeOverride(final RunningEffect triggerRE, final boolean trigger) { if (!this.isValueComputationEnabled()) { return; } if (this.m_caster == null || !(this.m_caster instanceof BasicCharacterInfo)) { return; } if (this.m_nbDepositMin <= 0) { return; } final List<AbstractDepositEffectArea> depositAreas = StaticEffectAreaManager.getInstance().getDepositAreas(); final short casterLevel = ((BasicCharacterInfo) this.m_caster).getLevel(); final int roll = MathHelper.random(100); boolean rareIsDiscovered = false; if (roll < this.m_discoverRareDepositPercentage) { rareIsDiscovered = true; } int nbDeposit = MathHelper.random(this.m_nbDepositMin, this.m_nbDepositMax + 1); if (rareIsDiscovered) { this.spawnRareDeposit(depositAreas, casterLevel); --nbDeposit; } for (int i = 0; i < nbDeposit; ++i) { this.spawnDeposit(depositAreas, casterLevel); } }
public static Vector3 lerp(Vector3 first, Vector3 second, float amount) { amount = MathHelper.clamp(0, 1, amount); float x = MathHelper.lerp(first.X, second.Y, amount); float y = MathHelper.lerp(first.Y, second.Y, amount); float z = MathHelper.lerp(first.Y, second.Y, amount); return new Vector3(x, y, z); }
public void a(IBlockAccess iblockaccess, Entity entity) { this.a = iblockaccess; this.b.c(); this.c = MathHelper.d(entity.width + 1.0F); this.d = MathHelper.d(entity.length + 1.0F); this.e = MathHelper.d(entity.width + 1.0F); }
public boolean canSpawn() { if (this.world.random.nextInt(3) == 0) { return false; } else { if (this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox)) { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.boundingBox.b); int k = MathHelper.floor(this.locZ); if (j < 63) { return false; } Block block = this.world.getType(i, j - 1, k); if (block == Blocks.GRASS || block.getMaterial() == Material.LEAVES) { return true; } } return false; } }
/** Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) { float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); par1 /= (double) f2; par3 /= (double) f2; par5 /= (double) f2; par1 += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) par8; par3 += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) par8; par5 += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) par8; par1 *= (double) par7; par3 *= (double) par7; par5 *= (double) par7; this.motionX = par1; this.motionY = par3; this.motionZ = par5; float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, (double) f3) * 180.0D / Math.PI); this.ticksInGround = 0; }
public void setHeading( double movementX, double movementY, double movementZ, double projectileSpeed, double projectileSpeed2) { float f = MathHelper.sqrt_double( movementX * movementX + movementY * movementY + movementZ * movementZ); movementX /= f; movementY /= f; movementZ /= f; movementX += rand.nextGaussian() * 0.0074999998323619366D * projectileSpeed2; movementY += rand.nextGaussian() * 0.0074999998323619366D * projectileSpeed2; movementZ += rand.nextGaussian() * 0.0074999998323619366D * projectileSpeed2; movementX *= projectileSpeed; movementY *= projectileSpeed; movementZ *= projectileSpeed; motionX = movementX; motionY = movementY; motionZ = movementZ; float f1 = MathHelper.sqrt_double(movementX * movementX + movementZ * movementZ); prevRotationYaw = rotationYaw = (float) ((Math.atan2(movementX, movementZ) * 180D) / Math.PI); prevRotationPitch = rotationPitch = (float) ((Math.atan2(movementY, f1) * 180D) / Math.PI); }
public boolean getCanSpawnHere() { int i = MathHelper.floor_double(posX); int j = MathHelper.floor_double(boundingBox.minY); int k = MathHelper.floor_double(posZ); return worldObj.getBlockId(i, j - 1, k) == Block.grass.blockID && worldObj.getFullBlockLightValue(i, j, k) > 8 && super.getCanSpawnHere(); }
/** Try to find and set a path to XYZ. Returns true if successful. */ public boolean tryMoveToXYZ(double par1, double par3, double par5, float par7) { PathEntity var8 = this.getPathToXYZ( (double) MathHelper.floor_double(par1), (double) ((int) par3), (double) MathHelper.floor_double(par5)); return this.setPath(var8, par7); }
public boolean d() { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.boundingBox.b); int k = MathHelper.floor(this.locZ); return this.world.getTypeId(i, j - 1, k) == Block.GRASS.id && this.world.k(i, j, k) > 8 && super.d(); }
// Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the // movement of arms and legs, where par1 represents the time(so that arms and legs swing back and // forth) and par2 represents how "far" arms and legs can swing at most. public void setRotationAngles( float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { this.head.rotateAngleY = par4 / (180F / (float) Math.PI); this.head.rotateAngleX = par5 / (180F / (float) Math.PI); this.leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; this.leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.4F * par2; this.leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.4F * par2; this.leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; }
public boolean func_75253_b() { if (field_75275_a.field_70170_p.func_72935_r()) { return false; } else { return !field_75274_b.field_75476_g && field_75274_b.func_75467_a( MathHelper.func_76128_c(field_75275_a.field_70165_t), MathHelper.func_76128_c(field_75275_a.field_70161_v)); } }
public void setRotationAngles( float par1, float par2, float par3, float par4, float par5, float par6) { // head.rotateAngleX = par5 / (180F / (float)Math.PI); head.rotateAngleY = par4 / (180F / (float) Math.PI); body.rotateAngleX = ((float) Math.PI / 2F); leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.2F * par2; leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.2F * par2; leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.2F * par2; leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.2F * par2; }
public boolean func_75250_a() { if (field_75275_a.field_70170_p.func_72935_r()) { return false; } Village village = field_75275_a.field_70170_p.field_72982_D.func_75550_a( MathHelper.func_76128_c(field_75275_a.field_70165_t), MathHelper.func_76128_c(field_75275_a.field_70163_u), MathHelper.func_76128_c(field_75275_a.field_70161_v), 16); if (village == null) { return false; } field_75274_b = village.func_75564_b( MathHelper.func_76128_c(field_75275_a.field_70165_t), MathHelper.func_76128_c(field_75275_a.field_70163_u), MathHelper.func_76128_c(field_75275_a.field_70161_v)); if (field_75274_b == null) { return false; } else { return (double) field_75274_b.func_75469_c( MathHelper.func_76128_c(field_75275_a.field_70165_t), MathHelper.func_76128_c(field_75275_a.field_70163_u), MathHelper.func_76128_c(field_75275_a.field_70161_v)) < 2.25D; } }
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { float f6 = f2 * 3.141593F * -0.1F; for (int i = 0; i < 4; i++) { field_40323_a[i].rotationPointY = -2F + MathHelper.cos(((float) (i * 2) + f2) * 0.25F); field_40323_a[i].rotationPointX = MathHelper.cos(f6) * 9F; field_40323_a[i].rotationPointZ = MathHelper.sin(f6) * 9F; f6 += 1.570796F; } f6 = 0.7853982F + f2 * 3.141593F * 0.03F; for (int j = 4; j < 8; j++) { field_40323_a[j].rotationPointY = 2.0F + MathHelper.cos(((float) (j * 2) + f2) * 0.25F); field_40323_a[j].rotationPointX = MathHelper.cos(f6) * 7F; field_40323_a[j].rotationPointZ = MathHelper.sin(f6) * 7F; f6 += 1.570796F; } f6 = 0.4712389F + f2 * 3.141593F * -0.05F; for (int k = 8; k < 12; k++) { field_40323_a[k].rotationPointY = 11F + MathHelper.cos(((float) k * 1.5F + f2) * 0.5F); field_40323_a[k].rotationPointX = MathHelper.cos(f6) * 5F; field_40323_a[k].rotationPointZ = MathHelper.sin(f6) * 5F; f6 += 1.570796F; } field_40322_b.rotateAngleY = f3 / 57.29578F; field_40322_b.rotateAngleX = f4 / 57.29578F; }
public boolean a() { if (this.a.world.r()) { return false; } else { Village village = this.a.world.villages.getClosestVillage( MathHelper.floor(this.a.locX), MathHelper.floor(this.a.locY), MathHelper.floor(this.a.locZ), 16); if (village == null) { return false; } else { this.b = village.b( MathHelper.floor(this.a.locX), MathHelper.floor(this.a.locY), MathHelper.floor(this.a.locZ)); return this.b == null ? false : (double) this.b.c( MathHelper.floor(this.a.locX), MathHelper.floor(this.a.locY), MathHelper.floor(this.a.locZ)) < 2.25D; } } }
public boolean g() { Chunk chunk = this.world.getChunkAtWorldCoords(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); return (this.getSize() == 1 || this.world.difficulty > 0) && this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 40.0D ? super.g() : false; }
/** * Calculates de (magic) damage done by the enchantment on a living entity based on level and * entity passed. */ public int calcModifierLiving(int par1, EntityLiving par2EntityLiving) { return this.damageType == 0 ? MathHelper.floor_float((float) par1 * 2.75F) : (this.damageType == 1 && par2EntityLiving.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD ? MathHelper.floor_float((float) par1 * 4.5F) : (this.damageType == 2 && par2EntityLiving.getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD ? MathHelper.floor_float((float) par1 * 4.5F) : 0)); }
public void t_() { this.P = this.locX; this.Q = this.locY; this.R = this.locZ; super.t_(); this.motX *= 1.15D; this.motZ *= 1.15D; this.motY += 0.04D; this.move(this.motX, this.motY, this.motZ); float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); this.yaw = (float) (MathHelper.b(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); for (this.pitch = (float) (MathHelper.b(this.motY, (double) f) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {; } while (this.pitch - this.lastPitch >= 180.0F) { this.lastPitch += 360.0F; } while (this.yaw - this.lastYaw < -180.0F) { this.lastYaw -= 360.0F; } while (this.yaw - this.lastYaw >= 180.0F) { this.lastYaw += 360.0F; } this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; if (this.ticksFlown == 0 && !this.R()) { this.world.makeSound(this, "fireworks.launch", 3.0F, 1.0F); } ++this.ticksFlown; if (this.world.isClientSide && this.ticksFlown % 2 < 2) { this.world.addParticle( EnumParticle.FIREWORKS_SPARK, this.locX, this.locY - 0.3D, this.locZ, this.random.nextGaussian() * 0.05D, -this.motY * 0.5D, this.random.nextGaussian() * 0.05D, new int[0]); } if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) { this.world.broadcastEntityEffect(this, (byte) 17); this.die(); } }
/** * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the * movement of arms and legs, where par1 represents the time(so that arms and legs swing back and * forth) and par2 represents how "far" arms and legs can swing at most. */ public void setRotationAngles( float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { float var8 = MathHelper.cos(par3 * 0.1F); this.field_82905_a[1].rotateAngleX = (0.065F + 0.05F * var8) * (float) Math.PI; this.field_82905_a[2].setRotationPoint( -2.0F, 6.9F + MathHelper.cos(this.field_82905_a[1].rotateAngleX) * 10.0F, -0.5F + MathHelper.sin(this.field_82905_a[1].rotateAngleX) * 10.0F); this.field_82905_a[2].rotateAngleX = (0.265F + 0.1F * var8) * (float) Math.PI; this.field_82904_b[0].rotateAngleY = par4 / (180F / (float) Math.PI); this.field_82904_b[0].rotateAngleX = par5 / (180F / (float) Math.PI); }
public void d(ItemStack itemstack, World world, EntityHuman entityhuman) { itemstack.b(world.b("map")); String s = "map_" + itemstack.getData(); WorldMap worldmap = new WorldMap(s); world.a(s, (WorldMapBase) worldmap); worldmap.b = MathHelper.floor(entityhuman.locX); worldmap.c = MathHelper.floor(entityhuman.locZ); worldmap.e = 3; worldmap.map = (byte) world.worldProvider.dimension; worldmap.a(); }
@Override public Point2 getScreenPosition(final IsoWorldScene scene, final IsoCamera isoCamera) { final float sensibility = 1.0f / isoCamera.getZoomFactor(); final Point2 delta = this.computeDeltaMouse(sensibility); final float maxDistance = 500.0f; delta.m_x = MathHelper.clamp(delta.m_x, -500.0f, 500.0f); delta.m_y = MathHelper.clamp(delta.m_y, -500.0f, 500.0f); Point2 point2 = delta; point2.m_x += this.m_startCameraScreenX; point2 = delta; point2.m_y += this.m_startCameraScreenY; return delta; }
public void o() { if (this.l.b()) { float f1 = this.b(1.0F); if (f1 > 0.5F && this.l.i(MathHelper.b(this.p), MathHelper.b(this.q), MathHelper.b(this.r)) && this.W.nextFloat() * 30.0F < (f1 - 0.4F) * 2.0F) { this.Z = 300; } } super.o(); }
/** Sets the models various rotation angles. */ public void setRotationAngles( float par1, float par2, float par3, float par4, float par5, float par6) { field_40340_a.rotateAngleY = par4 / (180F / (float) Math.PI); field_40340_a.rotateAngleX = par5 / (180F / (float) Math.PI); field_40339_c.rotationPointY = 3F; field_40339_c.rotationPointZ = -1F; field_40339_c.rotateAngleX = -0.75F; field_40336_d.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2 * 0.5F; field_40337_e.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.4F * par2 * 0.5F; field_40336_d.rotateAngleY = 0.0F; field_40337_e.rotateAngleY = 0.0F; }
public PathEntity a(double d0, double d1, double d2) { return !this.j() ? null : this.b.a( this.a, MathHelper.floor(d0), (int) d1, MathHelper.floor(d2), this.e, this.j, this.k, this.l, this.m); }
public void onLivingUpdate() { if (worldObj.isDaytime() && !worldObj.multiplayerWorld) { float f = getEntityBrightness(1.0F); if (f > 0.5F && worldObj.canBlockSeeTheSky( MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)) && rand.nextFloat() * 30F < (f - 0.4F) * 2.0F) { // setFire(8); } } super.onLivingUpdate(); }
/** Returns the path to the given coordinates */ public PathEntity getPathToXYZ(double par1, double par3, double par5) { return !this.canNavigate() ? null : this.worldObj.getEntityPathToXYZ( this.theEntity, MathHelper.floor_double(par1), (int) par3, MathHelper.floor_double(par5), this.pathSearchRange, this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); }