public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final Item par8Item ) { super( par1World, par2, par4, par6, par8Item ); this.particleGravity = 0; this.particleBlue = 1; this.particleGreen = 1; this.particleRed = 1; this.particleAlpha = 1.4f; this.particleScale = 3.5f; this.particleTextureIndex = ParticleTextures.BlockEnergyParticle; this.startBlkX = MathHelper.floor( this.posX ); this.startBlkY = MathHelper.floor( this.posY ); this.startBlkZ = MathHelper.floor( this.posZ ); }
@Override public int getMetadata(int stackMeta) { return MathHelper.clamp(stackMeta, 0, 15); }
/** * Sets throwable heading based on an entity that's throwing it */ public void shoot(Entity entityThrower, float rotationPitchIn, float rotationYawIn, float pitchOffset, float velocity, float inaccuracy) { float f = -MathHelper.sin(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F); float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * 0.017453292F); float f2 = MathHelper.cos(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F); this.shoot((double)f, (double)f1, (double)f2, velocity, inaccuracy); this.motionX += entityThrower.motionX; this.motionZ += entityThrower.motionZ; if (!entityThrower.onGround) { this.motionY += entityThrower.motionY; } }
/** * Updates the entity motion clientside, called by packets from the server */ @SideOnly(Side.CLIENT) public void setVelocity(double x, double y, double z) { this.motionX = x; this.motionY = y; this.motionZ = z; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt(x * x + z * z); this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI)); this.rotationPitch = (float)(MathHelper.atan2(y, (double)f) * (180D / Math.PI)); this.prevRotationYaw = this.rotationYaw; this.prevRotationPitch = this.rotationPitch; } }
private static void renderItemInFirstPerson(AbstractClientPlayer player, float partialTicks, float interpPitch, EnumHand hand, float swingProgress, ItemStack stack, float equipProgress) throws Throwable { // Cherry picked from ItemRenderer.renderItemInFirstPerson boolean flag = hand == EnumHand.MAIN_HAND; EnumHandSide enumhandside = flag ? player.getPrimaryHand() : player.getPrimaryHand().opposite(); GlStateManager.pushMatrix(); boolean flag1 = enumhandside == EnumHandSide.RIGHT; float f = -0.4F * MathHelper.sin(MathHelper.sqrt(swingProgress) * (float)Math.PI); float f1 = 0.2F * MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float)Math.PI * 2F)); float f2 = -0.2F * MathHelper.sin(swingProgress * (float)Math.PI); int i = flag1 ? 1 : -1; GlStateManager.translate(i * f, f1, f2); transformSideFirstPerson(enumhandside, equipProgress); transformFirstPerson(enumhandside, swingProgress); doRender(enumhandside, partialTicks, stack); GlStateManager.popMatrix(); }
private void calculatePistonPosition2(float crankAngleRadians, float radius, float length) { float cA = MathHelper.cos(crankAngleRadians); float sA = MathHelper.sin(crankAngleRadians); float pistonPos2 = radius * cA + MathHelper.sqrt(length * length - radius * radius * sA * sA); float bx = sA * radius; float by = cA * radius; float cx = -2f; armAngle2 = (float) Math.atan2(cx - bx, pistonPos2 - by); } }
public static float calculateLightRatio(World world) { int lightValue = EnumSkyBlock.SKY.defaultLightValue - world.getSkylightSubtracted(); float sunAngle = world.getCelestialAngleRadians(1.0F); if (sunAngle < (float) Math.PI) { sunAngle += (0.0F - sunAngle) * 0.2F; } else { sunAngle += (((float) Math.PI * 2F) - sunAngle) * 0.2F; } lightValue = Math.round(lightValue * MathHelper.cos(sunAngle)); lightValue = MathHelper.clamp(lightValue, 0, 15); return lightValue / 15f; }
@Override public boolean shouldEscapeWaterFast() { int radiusXZ = 4; for(BlockPos pos : BlockPos.getAllInBox(MathHelper.floor(this.posX - radiusXZ), MathHelper.floor(this.posY), MathHelper.floor(this.posZ - radiusXZ), MathHelper.ceil(this.posX + radiusXZ), MathHelper.ceil(this.posY), MathHelper.ceil(this.posZ + radiusXZ))) { if(!world.getBlockState(pos).getMaterial().isLiquid()) { return false; } } return false; }
@Override public boolean addLandingEffects(IBlockState state, net.minecraft.world.WorldServer world, BlockPos blockPosition, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles ) { float f = MathHelper.ceil(entity.fallDistance - 3.0F); double d0 = Math.min(0.2F + f / 15.0F, 10.0F); if (d0 > 2.5D) { d0 = 2.5D; } int i = (int)(150.0D * d0); world.spawnParticle(EnumParticleTypes.BLOCK_DUST, entity.posX, entity.posY, entity.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, Block.getStateId(ModBlocks.storage.getDefaultState().withProperty(BotaniaStateProps.STORAGE_VARIANT, StorageVariant.ELEMENTIUM))); return true; }
public float getDistanceFrom(Node node) { if (node == null) { return 0; } float x = this.x - node.x; float y = this.y - node.y; float z = this.z - node.z; return MathHelper.sqrt(x * x + y * y + z * z); }
public void faceEntity(Entity entityIn) { double d0 = entityIn.posX - this.posX; double d2 = entityIn.posZ - this.posZ; double d1; if (entityIn instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase) entityIn; d1 = entitylivingbase.posY + entitylivingbase.getEyeHeight() - (this.posY + this.getEyeHeight()); } else { d1 = (entityIn.getEntityBoundingBox().minY + entityIn.getEntityBoundingBox().maxY) / 2.0D - (this.posY + this.getEyeHeight()); } double d3 = MathHelper.sqrt(d0 * d0 + d2 * d2); rotationPitch = MathHelper.wrapDegrees((float) (-(MathHelper.atan2(d1, d3) * (180D / Math.PI)))); rotationYaw = MathHelper.wrapDegrees((float) (MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F); }
@Override public void faceTarget(float yaw, float pitch, float rotationDivisor, AdvancedModelRenderer... boxes) { float actualRotationDivisor = rotationDivisor * boxes.length; float yawAmount = MathHelper.clamp(MathHelper.wrapDegrees(yaw), -45.0F, 45.0F) / (180.0F / (float) Math.PI) / actualRotationDivisor; float pitchAmount = MathHelper.wrapDegrees(pitch) / (180.0F / (float) Math.PI) / actualRotationDivisor; for (AdvancedModelRenderer box : boxes) { box.rotateAngleY += yawAmount; box.rotateAngleX += pitchAmount; } } }
private double func_82214_u(int p_82214_1_) { if (p_82214_1_ <= 0) { return posX; } else { float f = (renderYawOffset + 180 * (p_82214_1_ - 1)) / 180.0F * (float)Math.PI; float f1 = MathHelper.cos(f); return posX + f1 * 1.3D; } }
@Override public int getExpDrop( IBlockState state, IBlockAccess world, BlockPos pos, int fortune ) { Random rand = world instanceof World ? ( (World) world ).rand : new Random(); if( this.getItemDropped( state, rand, fortune ) != Item.getItemFromBlock( this ) ) { return MathHelper.getInt( rand, 2, 5 ); } return super.getExpDrop( state, world, pos, fortune ); }
private double func_82213_w(int p_82213_1_) { if (p_82213_1_ <= 0) { return posZ; } else { float f = (renderYawOffset + 180 * (p_82213_1_ - 1)) / 180.0F * (float)Math.PI; float f1 = MathHelper.sin(f); return posZ + f1 * 1.3D; } } }
private static float getCheckingAngle(EntityLivingBase player, float base) { float yaw = MathHelper.wrapDegrees(player.rotationYaw) + 90F; int angles = 360; int segAngles = angles / SEGMENTS; float shift = segAngles / 2; if(yaw < 0) yaw = 180F + (180F + yaw); yaw -= 360F - base; float angle = 360F - yaw + shift; if(angle < 0) angle = 360F + angle; return angle; }
public static float[] vecToRotations(Vec3d vec) { float yaw = (float) MathHelper.atan2(vec.z, vec.x); float pitch = (float) Math.asin(vec.y / vec.length()); return new float[]{(float) Math.toDegrees(pitch), (float) Math.toDegrees(yaw) + 90}; }
private void calculatePistonPosition1(float crankAngleRadians, float radius, float length) { float cA = MathHelper.cos(crankAngleRadians); float sA = MathHelper.sin(crankAngleRadians); float pistonPos = radius * cA + MathHelper.sqrt(length * length - radius * radius * sA * sA); float bx = sA * radius; float by = cA * radius; float cx = 0; armAngle = (float) Math.atan2(cx - bx, pistonPos - by); }
/** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ public void shoot(double x, double y, double z, float velocity, float inaccuracy) { float f = MathHelper.sqrt(x * x + y * y + z * z); x = x / (double)f; y = y / (double)f; z = z / (double)f; x = x + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; y = y + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; z = z + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; x = x * (double)velocity; y = y * (double)velocity; z = z * (double)velocity; this.motionX = x; this.motionY = y; this.motionZ = z; float f1 = MathHelper.sqrt(x * x + z * z); this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI)); this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI)); this.prevRotationYaw = this.rotationYaw; this.prevRotationPitch = this.rotationPitch; this.ticksInGround = 0; }
private static void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_) { int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1; // Botania - added GlStateManager.translate(p_187453_1_ == EnumHandSide.RIGHT ? 0.2F : 0.52F, -0.125F, p_187453_1_ == EnumHandSide.RIGHT ? 0.6F : 0.25F); GlStateManager.rotate(p_187453_1_ == EnumHandSide.RIGHT ? 60F : 120F, 0F, 1F, 0F); GlStateManager.rotate(30F, 0F, 0F, -1F); // End add float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float)Math.PI); GlStateManager.rotate(i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F); float f1 = MathHelper.sin(MathHelper.sqrt(p_187453_2_) * (float)Math.PI); GlStateManager.rotate(i * f1 * -20.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(i * -45.0F, 0.0F, 1.0F, 0.0F); }