Java Code Examples for net.minecraft.util.math.MathHelper#sin()
The following examples show how to use
net.minecraft.util.math.MathHelper#sin() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Nuker.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public boolean canSeeBlock(BlockPos pos) { double diffX = pos.getX() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).x; double diffY = pos.getY() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).y; double diffZ = pos.getZ() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).z; double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ); float yaw = mc.player.yaw + MathHelper.wrapDegrees((float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90 - mc.player.yaw); float pitch = mc.player.pitch + MathHelper.wrapDegrees((float)-Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.pitch); Vec3d rotation = new Vec3d( (double)(MathHelper.sin(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)), (double)(-MathHelper.sin(pitch * 0.017453292F)), (double)(MathHelper.cos(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F))); Vec3d rayVec = mc.player.getCameraPosVec(mc.getTickDelta()).add(rotation.x * 6, rotation.y * 6, rotation.z * 6); return mc.world.rayTrace(new RayTraceContext(mc.player.getCameraPosVec(mc.getTickDelta()), rayVec, RayTraceContext.ShapeType.OUTLINE, RayTraceContext.FluidHandling.NONE, mc.player)) .getBlockPos().equals(pos); }
Example 2
Source File: CapeHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void resolve(EntityPlayer player, Point point) { float yaw = (float) Math.toRadians(player.renderYawOffset); float height; float back; if (player.isSneaking()) { height = 1.15F; back = getBack(player, 0.135F); } else { height = 1.38F; back = getBack(player, 0.14F); } float vx = MathHelper.cos(yaw) * x + MathHelper.cos(yaw - (float) Math.PI / 2) * back; float vz = MathHelper.sin(yaw) * x + MathHelper.sin(yaw - (float) Math.PI / 2) * back; point.posX = (float) player.posX + vx; point.posY = (float) player.posY + height + y; point.posZ = (float) player.posZ + vz; }
Example 3
Source File: RenderCyberlimbHand.java From Cyberware with MIT License | 6 votes |
private void renderMapFirstPersonSide(float p_187465_1_, EnumHandSide p_187465_2_, float p_187465_3_, ItemStack p_187465_4_) { float f = p_187465_2_ == EnumHandSide.RIGHT ? 1.0F : -1.0F; GlStateManager.translate(f * 0.125F, -0.125F, 0.0F); if (!this.mc.thePlayer.isInvisible()) { GlStateManager.pushMatrix(); GlStateManager.rotate(f * 10.0F, 0.0F, 0.0F, 1.0F); this.renderArmFirstPerson(p_187465_1_, p_187465_3_, p_187465_2_); GlStateManager.popMatrix(); } GlStateManager.pushMatrix(); GlStateManager.translate(f * 0.51F, -0.08F + p_187465_1_ * -1.2F, -0.75F); float f1 = MathHelper.sqrt_float(p_187465_3_); float f2 = MathHelper.sin(f1 * (float)Math.PI); float f3 = -0.5F * f2; float f4 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F)); float f5 = -0.3F * MathHelper.sin(p_187465_3_ * (float)Math.PI); GlStateManager.translate(f * f3, f4 - 0.3F * f2, f5); GlStateManager.rotate(f2 * -45.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(f * f2 * -30.0F, 0.0F, 1.0F, 0.0F); this.renderMapFirstPerson(p_187465_4_); GlStateManager.popMatrix(); }
Example 4
Source File: ModelSummonZombie.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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. */ @Override public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, @Nonnull Entity entityIn) { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); boolean flag = ((EntityBackupZombie) entityIn).isArmsRaised(); float f = MathHelper.sin(this.swingProgress * (float) Math.PI); float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI); this.bipedRightArm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F); this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F; float f2 = -(float) Math.PI / (flag ? 1.5F : 2.25F); this.bipedRightArm.rotateAngleX = f2; this.bipedLeftArm.rotateAngleX = f2; this.bipedRightArm.rotateAngleX += f * 1.2F - f1 * 0.4F; this.bipedLeftArm.rotateAngleX += f * 1.2F - f1 * 0.4F; this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F; }
Example 5
Source File: AbstractPonyModel.java From MineLittlePony with MIT License | 5 votes |
/** * Animates arm swinging. * * @param arm The arm to swing */ protected void swingArm(ModelPart arm) { float swing = 1 - (float)Math.pow(1 - getSwingAmount(), 3); float deltaX = MathHelper.sin(swing * PI); float deltaZ = MathHelper.sin(getSwingAmount() * PI); float deltaAim = deltaZ * (0.7F - head.pitch) * 0.75F; arm.pitch -= deltaAim + deltaX * 1.2F; arm.yaw += torso.yaw * 2; arm.roll = -deltaZ * 0.4F; }
Example 6
Source File: Angle.java From ForgeHax with MIT License | 5 votes |
public Vec3d getDirectionVector() { float cy = MathHelper.cos(-inDegrees().getYaw() * 0.017453292F - (float) Math.PI); float sy = MathHelper.sin(-inDegrees().getYaw() * 0.017453292F - (float) Math.PI); float cp = -MathHelper.cos(-inDegrees().getPitch() * 0.017453292F); float sp = MathHelper.sin(-inDegrees().getPitch() * 0.017453292F); return new Vec3d(sy * cp, sp, cy * cp); }
Example 7
Source File: PegasusWings.java From MineLittlePony with MIT License | 5 votes |
@Override public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { float flap = 0; float progress = pegasus.getSwingAmount(); if (progress > 0) { flap = MathHelper.sin(MathHelper.sqrt(progress) * PI * 2); } else { float pi = PI * (float) Math.pow(swing, 16); float mve = move * 0.6662f; // magic number ahoy (actually 2/3) float srt = swing / 4; flap = MathHelper.cos(mve + pi) * srt; } getLeft().rotateWalking(flap); getRight().rotateWalking(-flap); float flapAngle = ROTATE_270; if (pegasus.wingsAreOpen()) { flapAngle = pegasus.getWingRotationFactor(ticks); if (!pegasus.getAttributes().isCrouching && pegasus.isWearing(Wearable.SADDLE_BAGS)) { flapAngle -= 1F; } } if (!pegasus.isFlying()) { flapAngle = pegasus.getMetadata().getInterpolator(interpolatorId).interpolate("wingFlap", flapAngle, 10); } getLeft().rotateFlying(flapAngle); getRight().rotateFlying(-flapAngle); }
Example 8
Source File: ItemSheathKatana.java From Sakura_mod with MIT License | 5 votes |
@Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { EnumHand hand = entityLiving.getActiveHand(); //big sweep!!! entityLiving.swingArm(hand); float f = (float) entityLiving.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); f += EnchantmentHelper.getModifierForCreature(stack, entityLiving.getCreatureAttribute()) / 1.2F; float f3 = 4.0F + EnchantmentHelper.getSweepingDamageRatio(entityLiving) * f; float sweepingRatio = 1f+EnchantmentHelper.getSweepingDamageRatio(entityLiving); for (Entity entitylivingbase : worldIn.getEntitiesWithinAABB(Entity.class, entityLiving.getEntityBoundingBox().grow(1.4D + sweepingRatio * 1.2D, 0.3D + sweepingRatio * 0.15D, 1.4D + sweepingRatio * 1.2D))) { if (entitylivingbase != entityLiving && !entityLiving.isOnSameTeam(entitylivingbase)) { if (entitylivingbase instanceof EntityLivingBase) { if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isActiveItemStackBlocking()) { //disable shield ((EntityPlayer) entitylivingbase).disableShield(false); } ((EntityLivingBase) entitylivingbase).knockBack(entityLiving, 0.4F + 0.4F * EnchantmentHelper.getSweepingDamageRatio(entityLiving), MathHelper.sin(entityLiving.rotationYaw * 0.017453292F), (-MathHelper.cos(entityLiving.rotationYaw * 0.017453292F))); entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3); } if (entitylivingbase instanceof MultiPartEntityPart) { entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3); } } } worldIn.playSound(null, entityLiving.posX, entityLiving.posY, entityLiving.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, entityLiving.getSoundCategory(), 1.0F, 1.0F); if (worldIn instanceof WorldServer) { double d0 = (-MathHelper.sin(entityLiving.rotationYaw * 0.017453292F)); double d1 = MathHelper.cos(entityLiving.rotationYaw * 0.017453292F); ((WorldServer) worldIn).spawnParticle(EnumParticleTypes.SWEEP_ATTACK, entityLiving.posX + d0, entityLiving.posY + entityLiving.height * 0.5D, entityLiving.posZ + d1, 0, d0, 0.0D, d1, 0.0D); } dropHand(entityLiving, hand, setKatana(stack)); ((EntityPlayer) entityLiving).getCooldownTracker().setCooldown(katana, 15); }
Example 9
Source File: CapeFeature.java From MineLittlePony with MIT License | 5 votes |
@Override public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { M model = getContextModel(); if (player.hasSkinTexture() && !player.isInvisible() && player.isPartVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null && player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) { stack.push(); model.transform(BodyPart.BODY, stack); stack.translate(0, 0.24F, 0); model.getBodyPart(BodyPart.BODY).rotate(stack); double capeX = MathHelper.lerp(tickDelta, player.capeX, player.prevCapeX) - MathHelper.lerp(tickDelta, player.prevX, player.getX()); double capeY = MathHelper.lerp(tickDelta, player.capeY, player.prevCapeY) - MathHelper.lerp(tickDelta, player.prevY, player.getY()); double capeZ = MathHelper.lerp(tickDelta, player.capeZ, player.prevCapeZ) - MathHelper.lerp(tickDelta, player.prevZ, player.getZ()); float motionYaw = player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw); double sin = MathHelper.sin(motionYaw * PI / 180); double cos = (-MathHelper.cos(motionYaw * PI / 180)); float capeMotionY = (float) capeY * 10; if (capeMotionY < -6) capeMotionY = -6; if (capeMotionY > 32) capeMotionY = 32; float capeMotionX = (float) (capeX * sin + capeZ * cos) * 100; float diagMotion = (float) (capeX * cos - capeZ * sin) * 100; if (capeMotionX < 0) capeMotionX = 0; float camera = MathHelper.lerp(tickDelta, player.prevStrideDistance, player.strideDistance); capeMotionY += MathHelper.sin(MathHelper.lerp(tickDelta, player.prevHorizontalSpeed, player.horizontalSpeed) * 6) * 32 * camera; stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(2 + capeMotionX / 12 + capeMotionY)); stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion( diagMotion / 2)); stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-diagMotion / 2)); stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180)); stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.getCapeTexture())); model.renderCape(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV); stack.pop(); } }
Example 10
Source File: HandEntity.java From pycode-minecraft with MIT License | 5 votes |
public void moveForward(float distance) { Vec3d pos = this.getPositionVector(); float f1 = -MathHelper.sin(this.rotationYaw * 0.017453292F); float f2 = MathHelper.cos(this.rotationYaw * 0.017453292F); pos = pos.addVector(distance * f1, 0, distance * f2); this.setPosition(pos.xCoord, pos.yCoord, pos.zCoord); }
Example 11
Source File: RenderExplodingChicken.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
/** * Allows the render to do state modifications necessary before the model is rendered. */ protected void preRenderCallback(EntityExplodingChicken entitylivingbaseIn, float partialTickTime) { float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime); float f1 = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F; f = MathHelper.clamp(f, 0.0F, 1.0F); f = f * f; f = f * f; float f2 = (1.0F + f * 0.4F) * f1; float f3 = (1.0F + f * 0.1F) / f1; GlStateManager.scale(f2, f3, f2); }
Example 12
Source File: EntityGuard.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public void spawnSweepParticles() { double d0 = (double) (-MathHelper.sin(this.rotationYaw * 0.017453292F)); double d1 = (double) MathHelper.cos(this.rotationYaw * 0.017453292F); if (this.world instanceof WorldServer) { ((WorldServer) this.world).spawnParticle(EnumParticleTypes.SWEEP_ATTACK, this.posX + d0, this.posY + (double) this.height * 0.5D, this.posZ + d1, 0, d0, 0.0D, d1, 0.0D, new int[0]); } }
Example 13
Source File: AbstractPonyModel.java From MineLittlePony with MIT License | 5 votes |
protected void aimBow(ModelPart arm, float ticks) { arm.pitch = ROTATE_270 + head.pitch + (MathHelper.sin(ticks * 0.067F) * 0.05F); arm.yaw = head.yaw - 0.06F; arm.roll = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; if (isSneaking) { arm.pivotY += 4; } }
Example 14
Source File: PlayerFinderHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
@Override public void onRender(float partialTicks) { if(pos == null) return; // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glPushMatrix(); RenderUtils.applyRenderOffset(); // generate rainbow color float x = System.currentTimeMillis() % 2000 / 1000F; float red = 0.5F + 0.5F * MathHelper.sin(x * (float)Math.PI); float green = 0.5F + 0.5F * MathHelper.sin((x + 4F / 3F) * (float)Math.PI); float blue = 0.5F + 0.5F * MathHelper.sin((x + 8F / 3F) * (float)Math.PI); GL11.glColor4f(red, green, blue, 0.5F); // tracer line GL11.glBegin(GL11.GL_LINES); { // set start position Vec3d start = RotationUtils.getClientLookVec() .add(RenderUtils.getCameraPos()); // set end position Vec3d end = Vec3d.ofCenter(pos); // draw line GL11.glVertex3d(start.x, start.y, start.z); GL11.glVertex3d(end.x, end.y, end.z); } GL11.glEnd(); // block box { GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); RenderUtils.drawOutlinedBox(); GL11.glColor4f(red, green, blue, 0.25F); RenderUtils.drawSolidBox(); GL11.glPopMatrix(); } GL11.glPopMatrix(); // GL resets GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 15
Source File: HallowedOreFeature.java From the-hallow with MIT License | 4 votes |
protected boolean generateVeinPart(IWorld world, Random random, HallowedOreFeatureConfig oreFeatureConfig, double positiveX, double negativeX, double positiveZ, double negativeZ, double double_5, double double_6, int startX, int yPosition, int startZ, int xSize, int int_5) { int stonesPlaced = 0; BitSet bitSet = new BitSet(xSize * int_5 * xSize); Mutable blockPos = new Mutable(); double[] doubles_1 = new double[oreFeatureConfig.size * 4]; int counter; double currentX; double currentY; double currentZ; double double_15; for (counter = 0; counter < oreFeatureConfig.size; ++counter) { float progress = (float) counter / (float) oreFeatureConfig.size; currentX = MathHelper.lerp(progress, positiveX, negativeX); currentY = MathHelper.lerp(progress, double_5, double_6); currentZ = MathHelper.lerp(progress, positiveZ, negativeZ); double_15 = random.nextDouble() * (double) oreFeatureConfig.size / 16.0D; double double_11 = ((double) (MathHelper.sin(3.1415927F * progress) + 1.0F) * double_15 + 1.0D) / 2.0D; doubles_1[counter * 4 + 0] = currentX; doubles_1[counter * 4 + 1] = currentY; doubles_1[counter * 4 + 2] = currentZ; doubles_1[counter * 4 + 3] = double_11; } for (counter = 0; counter < oreFeatureConfig.size - 1; ++counter) { if (doubles_1[counter * 4 + 3] > 0.0D) { for (int int_9 = counter + 1; int_9 < oreFeatureConfig.size; ++int_9) { if (doubles_1[int_9 * 4 + 3] > 0.0D) { currentX = doubles_1[counter * 4 + 0] - doubles_1[int_9 * 4 + 0]; currentY = doubles_1[counter * 4 + 1] - doubles_1[int_9 * 4 + 1]; currentZ = doubles_1[counter * 4 + 2] - doubles_1[int_9 * 4 + 2]; double_15 = doubles_1[counter * 4 + 3] - doubles_1[int_9 * 4 + 3]; if (double_15 * double_15 > currentX * currentX + currentY * currentY + currentZ * currentZ) { if (double_15 > 0.0D) { doubles_1[int_9 * 4 + 3] = -1.0D; } else { doubles_1[counter * 4 + 3] = -1.0D; } } } } } } for (counter = 0; counter < oreFeatureConfig.size; ++counter) { double double_16 = doubles_1[counter * 4 + 3]; if (double_16 >= 0.0D) { double double_17 = doubles_1[counter * 4 + 0]; double double_18 = doubles_1[counter * 4 + 1]; double double_19 = doubles_1[counter * 4 + 2]; int int_11 = Math.max(MathHelper.floor(double_17 - double_16), startX); int int_12 = Math.max(MathHelper.floor(double_18 - double_16), yPosition); int int_13 = Math.max(MathHelper.floor(double_19 - double_16), startZ); int int_14 = Math.max(MathHelper.floor(double_17 + double_16), int_11); int int_15 = Math.max(MathHelper.floor(double_18 + double_16), int_12); int int_16 = Math.max(MathHelper.floor(double_19 + double_16), int_13); for (int x = int_11; x <= int_14; ++x) { double double_20 = ((double) x + 0.5D - double_17) / double_16; if (double_20 * double_20 < 1.0D) { for (int y = int_12; y <= int_15; ++y) { double double_21 = ((double) y + 0.5D - double_18) / double_16; if (double_20 * double_20 + double_21 * double_21 < 1.0D) { for (int z = int_13; z <= int_16; ++z) { double double_22 = ((double) z + 0.5D - double_19) / double_16; if (double_20 * double_20 + double_21 * double_21 + double_22 * double_22 < 1.0D) { int int_20 = x - startX + (y - yPosition) * xSize + (z - startZ) * xSize * int_5; if (!bitSet.get(int_20)) { bitSet.set(int_20); blockPos.set(x, y, z); if (world.getBlockState(blockPos).getBlock() == HallowedBlocks.TAINTED_STONE) { world.setBlockState(blockPos, oreFeatureConfig.state, 2); ++stonesPlaced; } } } } } } } } } } return stonesPlaced > 0; }
Example 16
Source File: ModulePlanetSelector.java From AdvancedRocketry with MIT License | 4 votes |
@SideOnly(Side.CLIENT) private void renderStarSystem(StellarBody star, int posX, int posY, float distanceZoomMultiplier, float planetSizeMultiplier) { int displaySize = (int)(planetSizeMultiplier*star.getDisplayRadius()); int offsetX = posX - displaySize/2; int offsetY = posY - displaySize/2; ModuleButton button; if(star.getSubStars() != null && !star.getSubStars().isEmpty()) { float phaseInc = 360/star.getSubStars().size(); float phase = 0; for(StellarBody star2 : star.getSubStars()) { displaySize = (int)(planetSizeMultiplier*star2.getDisplayRadius()); int deltaX, deltaY; deltaX = (int)(star2.getStarSeperation()*MathHelper.cos(phase)*0.5); deltaY = (int)(star2.getStarSeperation()*MathHelper.sin(phase)*0.5); planetList.add(button = new ModuleButton(offsetX + deltaX, offsetY + deltaY, star.getId() + starIdOffset, "", this, new ResourceLocation[] { TextureResources.locationSunNew }, String.format("Name: %s\nNumber of Planets: %d",star.getName(), star.getNumPlanets()), displaySize, displaySize)); button.setSound("buttonBlipA"); button.setBGColor(star2.getColorRGB8()); phase += phaseInc; } } displaySize = (int)(planetSizeMultiplier*star.getDisplayRadius()); offsetX = posX - displaySize/2; offsetY = posY - displaySize/2; planetList.add(button = new ModuleButton(offsetX, offsetY, star.getId() + starIdOffset, "", this, new ResourceLocation[] { TextureResources.locationSunNew }, String.format("Name: %s\nNumber of Planets: %d",star.getName(), star.getNumPlanets()), displaySize, displaySize)); button.setSound("buttonBlipA"); button.setBGColor(star.getColorRGB8()); renderPropertiesMap.put(star.getId() + starIdOffset, new PlanetRenderProperties(displaySize, offsetX, offsetY)); //prevMultiplier *= 0.25f; displaySize = (int)(planetSizeMultiplier*100); offsetX = posX - displaySize/2; offsetY = posY - displaySize/2; for(IDimensionProperties properties : star.getPlanets()) { if(planetDefiner != null && !planetDefiner.isPlanetKnown(properties)) continue; if(!properties.isMoon()) renderPlanets((DimensionProperties)properties, offsetX + displaySize/2, offsetY + displaySize/2, displaySize, distanceZoomMultiplier,planetSizeMultiplier); } moduleList.addAll(planetList); }
Example 17
Source File: ItemKatana.java From Sakura_mod with MIT License | 4 votes |
@Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.SWEEPING, stack); if (k > 0) { //big sweep!!! entityLiving.swingArm(entityLiving.getActiveHand()); float f = (float) entityLiving.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); f += EnchantmentHelper.getModifierForCreature(stack, entityLiving.getCreatureAttribute()) / 1.2F; float f3 = 2.0F + EnchantmentHelper.getSweepingDamageRatio(entityLiving) * f; float sweepingRatio = EnchantmentHelper.getSweepingDamageRatio(entityLiving); for (Entity entitylivingbase : worldIn.getEntitiesWithinAABB(Entity.class, entityLiving.getEntityBoundingBox().grow(1.4D + sweepingRatio * 1.2D, 0.3D + sweepingRatio * 0.15D, 1.4D + sweepingRatio * 1.2D))) { if (entitylivingbase != entityLiving && !entityLiving.isOnSameTeam(entitylivingbase)) { if (entitylivingbase instanceof EntityLivingBase) { if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isActiveItemStackBlocking()) { //disable shield ((EntityPlayer) entitylivingbase).disableShield(false); } ((EntityLivingBase) entitylivingbase).knockBack(entityLiving, 0.4F + 0.4F * EnchantmentHelper.getSweepingDamageRatio(entityLiving), MathHelper.sin(entityLiving.rotationYaw * 0.017453292F), (-MathHelper.cos(entityLiving.rotationYaw * 0.017453292F))); entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3); } if (entitylivingbase instanceof MultiPartEntityPart) { entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3); } } } worldIn.playSound(null, entityLiving.posX, entityLiving.posY, entityLiving.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, entityLiving.getSoundCategory(), 1.0F, 1.0F); if (worldIn instanceof WorldServer) { double d0 = (-MathHelper.sin(entityLiving.rotationYaw * 0.017453292F)); double d1 = MathHelper.cos(entityLiving.rotationYaw * 0.017453292F); ((WorldServer) worldIn).spawnParticle(EnumParticleTypes.SWEEP_ATTACK, entityLiving.posX + d0, entityLiving.posY + entityLiving.height * 0.5D, entityLiving.posZ + d1, 0, d0, 0.0D, d1, 0.0D); } stack.damageItem(2, entityLiving); ((EntityPlayer) entityLiving).getCooldownTracker().setCooldown(this, 25); } }
Example 18
Source File: EntityUIPlanet.java From AdvancedRocketry with MIT License | 4 votes |
public void setPositionPolar(double originX, double originY, double originZ, double radius, double theta) { originX += radius*MathHelper.cos((float) theta); originZ += radius*MathHelper.sin((float) theta); setPosition(originX, originY, originZ); }
Example 19
Source File: ZomponyModel.java From MineLittlePony with MIT License | 4 votes |
public boolean islookAngleRight(float move) { return MathHelper.sin(move / 20) < 0; }
Example 20
Source File: ItemJetpack.java From AdvancedRocketry with MIT License | 4 votes |
@Override public void onAccelerate(ItemStack stack, IInventory inv, EntityPlayer player) { boolean hasFuel = false; MODES mode = getMode(stack); for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack fuelTank = inv.getStackInSlot(i); if(FluidUtils.containsFluid(fuelTank, AdvancedRocketryFluids.fluidHydrogen)) { hasFuel = FluidUtils.getFluidHandler(fuelTank).drain(1,true) != null; if(hasFuel) break; } } if(hasFuel) { if(mode == MODES.HOVER) { if(Configuration.jetPackThrust > DimensionManager.getInstance().getDimensionProperties(player.world.provider.getDimension()).getGravitationalMultiplier()) player.capabilities.isFlying = true; } else player.addVelocity(0, (double)Configuration.jetPackThrust*0.1f, 0); if(player.world.isRemote) { double xPos = player.posX; double zPos = player.posZ; float playerRot = (float) ((Math.PI/180f)*(player.rotationYaw - 55)); xPos = player.posX + MathHelper.cos(playerRot)*.4f; zPos = player.posZ + MathHelper.sin(playerRot)*.4f; float ejectSpeed = mode == MODES.HOVER ? 0.1f : 0.3f; //AdvancedRocketry.proxy.spawnParticle("smallRocketFlame", player.worldObj, xPos, player.posY - 0.75, zPos, (player.worldObj.rand.nextFloat() - 0.5f)/18f,-.1 ,(player.worldObj.rand.nextFloat() - 0.5f)/18f); AdvancedRocketry.proxy.spawnParticle("smallRocketFlame", player.world, xPos, player.posY + 0.75, zPos, 0, player.motionY -ejectSpeed ,0); playerRot = (float) ((Math.PI/180f)*(player.rotationYaw - 125)); xPos = player.posX + MathHelper.cos(playerRot)*.4f; zPos = player.posZ + MathHelper.sin(playerRot)*.4f; AdvancedRocketry.proxy.spawnParticle("smallRocketFlame", player.world, xPos, player.posY + 0.75, zPos, 0, player.motionY -ejectSpeed ,0); } if(player.motionY > -1) { player.fallDistance = 0; } } }