net.minecraft.util.math.MathHelper Java Examples
The following examples show how to use
net.minecraft.util.math.MathHelper.
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: HopperMinecartEntity_transferItemsOutFeatureMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 6 votes |
private Vec3d getBlockBelowCartOffset(){ BlockState blockState_1 = this.world.getBlockState(new BlockPos(MathHelper.floor(this.getX()), MathHelper.floor(this.getY()), MathHelper.floor(this.getZ()))); if (blockState_1.matches(BlockTags.RAILS)) { RailShape railShape = (RailShape)blockState_1.get(((AbstractRailBlock)blockState_1.getBlock()).getShapeProperty()); switch (railShape){ case ASCENDING_EAST: return ascending_east_offset; case ASCENDING_WEST: return ascending_west_offset; case ASCENDING_NORTH: return ascending_north_offset; case ASCENDING_SOUTH: return ascending_south_offset; default: return upwardVec; } } return upwardVec; }
Example #2
Source File: RenderCodex.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
private static void renderItemInFirstPerson(AbstractClientPlayer player, EnumHand hand, float swingProgress, ItemStack stack, float equipProgress) { // 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); RenderCodex.INSTANCE.doRender(enumhandside, stack); GlStateManager.popMatrix(); }
Example #3
Source File: EntityTofuFish.java From TofuCraftReload with MIT License | 6 votes |
public void onUpdateMoveHelper() { if (this.fish.isInWater()) { this.fish.motionY += 0.005D; } if (this.action == EntityMoveHelper.Action.MOVE_TO && !this.fish.getNavigator().noPath()) { double d0 = this.posX - this.fish.posX; double d1 = this.posY - this.fish.posY; double d2 = this.posZ - this.fish.posZ; double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); d1 = d1 / d3; float f = (float)(MathHelper.atan2(d2, d0) * (double)(180F / (float)Math.PI)) - 90.0F; this.fish.rotationYaw = this.limitAngle(this.fish.rotationYaw, f, 90.0F); this.fish.renderYawOffset = this.fish.rotationYaw; float f1 = (float)(this.speed * this.fish.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getBaseValue()); this.fish.setAIMoveSpeed(this.fish.getAIMoveSpeed() + (f1 - this.fish.getAIMoveSpeed()) * 0.125F); this.fish.motionY += (double)this.fish.getAIMoveSpeed() * d1 * 0.1D; } else { this.fish.setAIMoveSpeed(0.0F); } }
Example #4
Source File: EntityUtils.java From ForgeHax with MIT License | 6 votes |
public static boolean isInWater(Entity entity) { if (entity == null) { return false; } double y = entity.posY + 0.01; for (int x = MathHelper.floor(entity.posX); x < MathHelper.ceil(entity.posX); x++) { for (int z = MathHelper.floor(entity.posZ); z < MathHelper.ceil(entity.posZ); z++) { BlockPos pos = new BlockPos(x, (int) y, z); if (getWorld().getBlockState(pos).getBlock() instanceof BlockLiquid) { return true; } } } return false; }
Example #5
Source File: SwitchHeldItemAndRotationPacket.java From Cyberware with MIT License | 6 votes |
public static void faceEntity(Entity player, Entity entityIn) { double d0 = entityIn.posX - player.posX; double d2 = entityIn.posZ - player.posZ; double d1; if (entityIn instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)entityIn; d1 = entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() - (player.posY + (double)player.getEyeHeight()); } else { d1 = (entityIn.getEntityBoundingBox().minY + entityIn.getEntityBoundingBox().maxY) / 2.0D - (player.posY + (double)player.getEyeHeight()); } double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); float f = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F; float f1 = (float)(-(MathHelper.atan2(d1, d3) * (180D / Math.PI))); player.rotationPitch = f1; player.rotationYaw = f; }
Example #6
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public boolean useHoeArea(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, int rWidth, int rHeight) { boolean northSouth = (((int)MathHelper.floor(player.rotationYaw * 4.0f / 360.0f + 0.5f)) & 1) == 0; boolean retValue = false; if (northSouth == false) { int tmp = rWidth; rWidth = rHeight; rHeight = tmp; } for (int x = pos.getX() - rWidth; x <= (pos.getX() + rWidth); ++x) { for (int z = pos.getZ() - rHeight; z <= (pos.getZ() + rHeight); ++z) { retValue |= this.useHoe(stack, player, world, new BlockPos(x, pos.getY(), z), side); } } return retValue; }
Example #7
Source File: TickHandler.java From GokiStats with MIT License | 6 votes |
private void handleFurnace(EntityPlayer player) { if (DataHelper.getPlayerStatLevel(player, Stats.FURNACE_FINESSE) > 0) { ArrayList<TileEntityFurnace> furnacesAroundPlayer = new ArrayList<>(); for (TileEntity listEntity : player.world.loadedTileEntityList) { if (listEntity != null) { TileEntity tileEntity = listEntity; BlockPos pos = tileEntity.getPos(); if (tileEntity instanceof TileEntityFurnace && MathHelper.sqrt(player.getDistanceSq(pos)) < 4.0D) { // TODO work out alter way to do tileEntity furnacesAroundPlayer.add((TileEntityFurnace) tileEntity); } } } // FIXME Laggy for (TileEntityFurnace furnace : furnacesAroundPlayer) if (furnace.isBurning()) for (int i = 0; i < Stats.FURNACE_FINESSE.getBonus(player); i++) // Intend to "mount" ticks, same as Torcherino. furnace.update(); } }
Example #8
Source File: CrowEntityModel.java From the-hallow with MIT License | 6 votes |
@Override public void setAngles(CrowEntity crow, float limbAngle, float limbDistance, float age, float headYaw, float headPitch) { head.pitch = headPitch * 0.017453292F; head.yaw = headYaw * 0.017453292F; if (crow.isInAir()) { leftLeg.pitch = 0.55F; rightLeg.pitch = 0.55F; this.leftWing.roll = 0.0873F + age; this.rightWing.roll = -0.0873F - age; } else { leftLeg.pitch = -0.6109F + MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance; rightLeg.pitch = -0.6109F + MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 1.4F * limbDistance; leftWing.roll = 0F; rightWing.roll = 0F; } }
Example #9
Source File: SpeedComponent.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); final DecimalFormat df = new DecimalFormat("#.#"); final double deltaX = Minecraft.getMinecraft().player.posX - Minecraft.getMinecraft().player.prevPosX; final double deltaZ = Minecraft.getMinecraft().player.posZ - Minecraft.getMinecraft().player.prevPosZ; final float tickRate = (Minecraft.getMinecraft().timer.tickLength / 1000.0f); final String bps = "BPS: " + df.format((MathHelper.sqrt(deltaX * deltaX + deltaZ * deltaZ) / tickRate)); this.setW(Minecraft.getMinecraft().fontRenderer.getStringWidth(bps)); this.setH(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT); //RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x90222222); Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(bps, this.getX(), this.getY(), -1); }
Example #10
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
private double getFluidLevelForTank(BlockPos tankPos) { if (!isTankController()) { MetaTileEntityTank controller = getControllerEntity(); return controller == null ? 0.0 : controller.getFluidLevelForTank(tankPos); } FluidStack fluidStack = multiblockFluidTank.getFluid(); if (fluidStack == null) { return 0.0; } double fluidLevel = multiblockFluidTank.getFluidAmount() / (1.0 * multiblockFluidTank.getCapacity()); double resultLevel; if (fluidStack.getFluid().isGaseous(fluidStack)) { resultLevel = fluidLevel; } else { int tankOffset = (tankPos.getY() - getPos().getY()); resultLevel = fluidLevel * multiblockSize.getY() - tankOffset; } return MathHelper.clamp(resultLevel, 0.0, 1.0); }
Example #11
Source File: ModelDabSquirrel.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { float f = limbSwing; float f1 = limbSwingAmount; this.lArm01.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.5F * f1 - 0.20943951023931953F; this.rArm01.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 0.5F * f1 - 0.20943951023931953F; this.rLeg01.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.5F * f1 - 0.17453292519943295F; this.lLeg01.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 0.5F * f1 - 0.17453292519943295F; this.tail01.rotateAngleX = MathHelper.sin(f * 0.2F) * 0.5F * f1 - (float) Math.toRadians(30); if (entityIn instanceof EntityLiving) { EntityLiving e = (EntityLiving) entityIn; float yawOffset = interpolateRotation(e.prevRenderYawOffset, e.renderYawOffset, Minecraft.getMinecraft().getRenderPartialTicks()); float yawHead = interpolateRotation(e.prevRotationYawHead, e.rotationYawHead, Minecraft.getMinecraft().getRenderPartialTicks()); this.neck.rotateAngleX = (e.prevRotationPitch + (e.rotationPitch - e.prevRotationPitch) * Minecraft.getMinecraft().getRenderPartialTicks()) * 0.017453292F - 13; this.neck.rotateAngleY = (yawHead - yawOffset) * 0.017453292F * 0.5F; //if (entityIn instanceof EntityDabSquirrel) { //EntityDabSquirrel ent = (EntityDabSquirrel) e; //this.chest.rotateAngleX = ent.isBesideClimbableBlock() ? (float) Math.toRadians(-90) : 0.10471975511965977F; //} } super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); }
Example #12
Source File: BleachFileHelper.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public static void readSettings() { List<String> lines = BleachFileMang.readFileLines("settings.txt"); for (Module m: ModuleManager.getModules()) { for (String s: lines) { String[] line = s.split(":"); if (!line[0].startsWith(m.getName())) continue; int count = 0; for (SettingBase set: m.getSettings()) { try { if (set instanceof SettingSlider) { m.getSettings().get(count).toSlider().setValue(Double.parseDouble(line[count+1]));} if (set instanceof SettingMode) { m.getSettings().get(count).toMode().mode = MathHelper.clamp(Integer.parseInt(line[count+1]), 0, m.getSettings().get(count).toMode().modes.length - 1);} if (set instanceof SettingToggle) { m.getSettings().get(count).toToggle().state = Boolean.parseBoolean(line[count+1]);} } catch (Exception e) {} count++; } } } }
Example #13
Source File: SliderWidget.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readUpdateInfo(int id, PacketBuffer buffer) { if (id == 1) { this.sliderPosition = buffer.readFloat(); this.sliderPosition = MathHelper.clamp(sliderPosition, 0.0f, 1.0f); this.displayString = getDisplayString(); } }
Example #14
Source File: BlockFrame.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { entityIn.motionX = MathHelper.clamp(entityIn.motionX, -0.15, 0.15); entityIn.motionZ = MathHelper.clamp(entityIn.motionZ, -0.15, 0.15); entityIn.fallDistance = 0.0F; if (entityIn.motionY < -0.15D) { entityIn.motionY = -0.15D; } if (entityIn.isSneaking() && entityIn.motionY < 0.0D) { entityIn.motionY = 0.0D; } if (entityIn.collidedHorizontally) { entityIn.motionY = 0.2; } }
Example #15
Source File: TileEntityCreationStation.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * Adds one more of each item in the recipe into the crafting grid, if possible * @param invId * @param recipeId */ protected boolean addOneSetOfRecipeItemsIntoGrid(IItemHandler invCrafting, int invId, int recipeId, EntityPlayer player) { invId = MathHelper.clamp(invId, 0, 1); int maskOreDict = invId == 1 ? MODE_BIT_RIGHT_CRAFTING_OREDICT : MODE_BIT_LEFT_CRAFTING_OREDICT; boolean useOreDict = (this.modeMask & maskOreDict) != 0; IItemHandlerModifiable playerInv = (IItemHandlerModifiable) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP); IItemHandler invWrapper = new CombinedInvWrapper(this.itemInventory, playerInv); NonNullList<ItemStack> template = this.getRecipeItems(invId); InventoryUtils.clearInventoryToMatchTemplate(invCrafting, invWrapper, template); return InventoryUtils.restockInventoryBasedOnTemplate(invCrafting, invWrapper, template, 1, true, useOreDict); }
Example #16
Source File: ContainerHandyChest.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void addCustomInventorySlots() { int customInvStart = this.inventorySlots.size(); int tier = MathHelper.clamp(this.tehc.getStorageTier(), 0, 3); int posX = 8; int posY = tier <= 2 ? 41 : 13; int rows = tier <= 2 ? (tier + 1) * 2 : 8; int columns = tier == 3 ? 13 : 9; // Item inventory slots for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { this.addSlotToContainer(new SlotItemHandlerGeneric(this.inventory, row * columns + col, posX + col * 18, posY + row * 18)); } } this.customInventorySlots = new MergeSlotRange(customInvStart, this.inventorySlots.size() - customInvStart); // Add the module slots as a priority slot range for shift+click merging this.addMergeSlotRangePlayerToExt(this.inventorySlots.size(), 4); this.cardSlots = new SlotRange(this.inventorySlots.size(), 4); posX = tier <= 2 ? 98 : 224; posY = tier <= 2 ? 8 : 174; int modX = tier == 3 ? 0 : 18; int modY = tier == 3 ? 18 : 0; // The Storage Module slots for (int i = 0; i < 4; i++) { this.addSlotToContainer(new SlotItemHandlerModule(this.tehc.getModuleInventory(), i, posX + i * modX, posY + i * modY, ModuleType.TYPE_MEMORY_CARD_ITEMS)); } }
Example #17
Source File: ModuleShapeSelf.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void renderSpell(World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) { IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class); if (overrides.onRenderSelf(world, spell, spellRing)) return; Entity caster = spell.getCaster(world); if (caster == null) return; ParticleBuilder glitter = new ParticleBuilder(30); glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED)); glitter.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f)); glitter.enableMotionCalculation(); ParticleSpawner.spawn(glitter, world, new StaticInterp<>(caster.getPositionVector()), 50, 5, (i, build) -> { double radius = 1; double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat(); double r = radius * RandUtil.nextFloat(); double x = r * MathHelper.cos((float) theta); double z = r * MathHelper.sin((float) theta); build.setPositionOffset(new Vec3d( RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5) )); build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.2f, 1f), 0f)); build.setMotion(new Vec3d(x, RandUtil.nextDouble(radius / 2.0, radius), z).normalize().scale(RandUtil.nextFloat())); build.setAcceleration(Vec3d.ZERO); build.setLifetime(50); build.setDeceleration(new Vec3d(0.8, 0.8, 0.8)); if (RandUtil.nextBoolean()) { build.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor())); } else { build.setColorFunction(new InterpColorHSV(spellRing.getSecondaryColor(), spellRing.getPrimaryColor())); } }); }
Example #18
Source File: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) { MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos); if (metaTileEntity == null) { return false; } CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); Matrix4 translation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()); BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (metaTileEntity.canRenderInLayer(renderLayer)) { renderState.lightMatrix.locate(world, pos); IVertexOperation[] pipeline = new IVertexOperation[]{renderState.lightMatrix}; metaTileEntity.renderMetaTileEntity(renderState, translation.copy(), pipeline); } Matrix4 coverTranslation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()); metaTileEntity.renderCovers(renderState, coverTranslation, renderLayer); if (metaTileEntity.isFragile() && renderLayer == BlockRenderLayer.CUTOUT) { TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); Random posRand = new Random(MathHelper.getPositionRandom(pos)); int destroyStage = posRand.nextInt(10); TextureAtlasSprite atlasSprite = textureMap.getAtlasSprite("minecraft:blocks/destroy_stage_" + destroyStage); for (EnumFacing face : EnumFacing.VALUES) { Textures.renderFace(renderState, translation, new IVertexOperation[0], face, Cuboid6.full, atlasSprite); } } return true; }
Example #19
Source File: MathUtil.java From seppuku with GNU General Public License v3.0 | 5 votes |
public static float[] calcAngle(Vec3d from, Vec3d to) { final double difX = to.x - from.x; final double difY = (to.y - from.y) * -1.0F; final double difZ = to.z - from.z; final double dist = MathHelper.sqrt(difX * difX + difZ * difZ); return new float[]{(float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(difZ, difX)) - 90.0f), (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(difY, dist)))}; }
Example #20
Source File: MixinEntity.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Redirect(method = "createRunningParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;floor(D)I", ordinal = 0)) public int runningParticlesFirstFloor(double d) { PhysicsWrapperEntity worldBelow = thisAsDraggable.getWorldBelowFeet(); if (worldBelow == null) { searchVector = null; return MathHelper.floor(d); } else { searchVector = new Vector(this.posX, this.posY - 0.20000000298023224D, this.posZ); // searchVector.transform(worldBelow.wrapping.coordTransform.wToLTransform); worldBelow.getPhysicsObject().getShipTransformationManager().getCurrentTickTransform() .transform(searchVector, TransformType.GLOBAL_TO_SUBSPACE); return MathHelper.floor(searchVector.X); } }
Example #21
Source File: HallowedOreFeature.java From the-hallow with MIT License | 5 votes |
@Override public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random random, BlockPos blockPos, HallowedOreFeatureConfig oreFeatureConfig) { float randomNumberFromZeroToPi = random.nextFloat() * 3.1415927F; float dividedSize = (float) oreFeatureConfig.size / 8.0F; int ceilSize = MathHelper.ceil(((float) oreFeatureConfig.size / 16.0F * 2.0F + 1.0F) / 2.0F); double positiveX = (blockPos.getX() + MathHelper.sin(randomNumberFromZeroToPi) * dividedSize); double negativeX = (blockPos.getX() - MathHelper.sin(randomNumberFromZeroToPi) * dividedSize); double positiveZ = (blockPos.getZ() + MathHelper.cos(randomNumberFromZeroToPi) * dividedSize); double negativeZ = (blockPos.getZ() - MathHelper.cos(randomNumberFromZeroToPi) * dividedSize); double positiveY = (blockPos.getY() + random.nextInt(3) - 2); double negativeY = (blockPos.getY() + random.nextInt(3) - 2); int startX = blockPos.getX() - MathHelper.ceil(dividedSize) - ceilSize; int y = blockPos.getY() - 2 - ceilSize; int startZ = blockPos.getZ() - MathHelper.ceil(dividedSize) - ceilSize; int xSize = 2 * (MathHelper.ceil(dividedSize) + ceilSize); int int_7 = 2 * (2 + ceilSize); for (int x = startX; x <= startX + xSize; ++x) { for (int z = startZ; z <= startZ + xSize; ++z) { if (y <= world.getTopY(Type.OCEAN_FLOOR_WG, x, z)) { return this.generateVeinPart(world, random, oreFeatureConfig, positiveX, negativeX, positiveZ, negativeZ, positiveY, negativeY, startX, y, startZ, xSize, int_7); } } } return false; }
Example #22
Source File: ModelBigCat.java From TFC2 with GNU General Public License v3.0 | 5 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 p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { float f6 = (180F / (float)Math.PI); this.HEAD.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI); this.HEAD.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI); this.LegLEFTFRONT.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.0F * p_78087_2_; this.LegLEFTREAR.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.4662F + (float)Math.PI) * 1.0F * p_78087_2_; this.LegRIGHTFRONT.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.0F * p_78087_2_; this.LegRIGHTREAR.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.4662F) * 1.0F * p_78087_2_; }
Example #23
Source File: BlockSakuraDiamondOre.java From Sakura_mod with MIT License | 5 votes |
@Override public int getExpDrop(IBlockState state, net.minecraft.world.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, 3, 7); } return 0; }
Example #24
Source File: EntityMonolithEye.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
protected void attackWithArrow(EntityLivingBase target) { int charge = 2 + rand.nextInt(10); EntityArrow entityarrow = new EntityTippedArrow(this.world, this); double d0 = target.posX - this.posX; double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityarrow.posY; double d2 = target.posZ - this.posZ; double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().getDifficultyId() * 4)); int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this); int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this); entityarrow.setDamage((double) (charge * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.world.getDifficulty().getDifficultyId() * 0.11F)); if (i > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); } if (j > 0) { entityarrow.setKnockbackStrength(j); } if (rand.nextBoolean()) { entityarrow.setFire(100); } this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entityarrow); }
Example #25
Source File: TileEntityTeleportRail.java From Signals with GNU General Public License v3.0 | 5 votes |
public Pair<MCPos, MCPos> getAllowedDestinationRange(World destinationDimension){ if(destinationDimension == null) return null; double moveFactor = getWorld().provider.getMovementFactor() / destinationDimension.provider.getMovementFactor(); double destX = MathHelper.clamp(getPos().getX() * moveFactor, destinationDimension.getWorldBorder().minX() + 16.0D, destinationDimension.getWorldBorder().maxX() - 16.0D); double destZ = MathHelper.clamp(getPos().getZ() * moveFactor, destinationDimension.getWorldBorder().minZ() + 16.0D, destinationDimension.getWorldBorder().maxZ() - 16.0D); destX = MathHelper.clamp((int)destX, -29999872, 29999872); destZ = MathHelper.clamp((int)destZ, -29999872, 29999872); int maxDiff = 8; MCPos min = new MCPos(destinationDimension, new BlockPos(destX - maxDiff, 0, destZ - maxDiff)); MCPos max = new MCPos(destinationDimension, new BlockPos(destX + maxDiff, destinationDimension.getActualHeight(), destZ + maxDiff)); return new ImmutablePair<MCPos, MCPos>(min, max); }
Example #26
Source File: IPegasus.java From MineLittlePony with MIT License | 5 votes |
/** * Determines angle used to animate wing flaps whilst flying/swimming. * * @param ticks Partial render ticks */ default float getWingRotationFactor(float ticks) { if (getAttributes().isSwimming) { return (MathHelper.sin(ticks * 0.136f) / 2) + ROTATE_270; } if (isFlying()) { return MathHelper.sin(ticks * 0.536f) + ROTATE_270 + 0.4f; } return WING_ROT_Z_SNEAK; }
Example #27
Source File: SpellRing.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
/** * Get a modifier in this ring between the range. Returns the attribute value, modified by burnout and multipliers, for use in a spell. * * @param world * @param attribute The attribute you want. List in {@link AttributeRegistry} for default attributeModifiers. * @param data The data of the spell being cast, used to get caster-specific modifiers. * @return The {@code double} potency of a modifier. */ public final float getAttributeValue(World world, Attribute attribute, SpellData data) { if (module == null) return 0; float current = FixedPointUtils.getDoubleFromNBT(informationTag, attribute.getNbtName()); AttributeRange range = module.getAttributeRanges().get(attribute); current = MathHelper.clamp(current, range.min, range.max); current = data.getCastTimeValue(attribute, current); current *= getPlayerBurnoutMultiplier(world, data); current *= getPowerMultiplier(); return current; }
Example #28
Source File: ShapesRenderer.java From fabric-carpet with MIT License | 5 votes |
public static void drawSphereFaces(Tessellator tessellator, BufferBuilder builder, float cx, float cy, float cz, float r, int subd, float red, float grn, float blu, float alpha) { float step = (float)Math.PI / (subd/2); int num_steps180 = (int)(Math.PI / step)+1; int num_steps360 = (int)(2*Math.PI / step); for (int i = 0; i <= num_steps360; i++) { float theta = i * step; float thetaprime = theta+step; builder.begin(GL11.GL_QUAD_STRIP, VertexFormats.POSITION_COLOR); for (int j = 0; j <= num_steps180; j++) { float phi = j * step; float x = r * MathHelper.sin(phi) * MathHelper.cos(theta); float z = r * MathHelper.sin(phi) * MathHelper.sin(theta); float y = r * MathHelper.cos(phi); float xp = r * MathHelper.sin(phi) * MathHelper.cos(thetaprime); float zp = r * MathHelper.sin(phi) * MathHelper.sin(thetaprime); builder.vertex(x + cx, y + cy, z + cz).color(red, grn, blu, alpha).next(); builder.vertex(xp + cx, y + cy, zp + cz).color(red, grn, blu, alpha).next(); } tessellator.draw(); } }
Example #29
Source File: MixinEntityLivingBase.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
private boolean isOnLadderOriginalButSlightlyOptimized() { int i = MathHelper.floor(this.posX); int j = MathHelper.floor(this.getEntityBoundingBox().minY); int k = MathHelper.floor(this.posZ); BlockPos blockpos = new BlockPos(i, j, k); IBlockState iblockstate = this.world.getBlockState(blockpos); return net.minecraftforge.common.ForgeHooks .isLivingOnLadder(iblockstate, world, new BlockPos(i, j, k), EntityLivingBase.class.cast(this)); }
Example #30
Source File: ModuleEffectTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) { Entity victim = spell.getVictim(world); if (victim == null) return; ParticleBuilder glitter = new ParticleBuilder(30); glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor())); glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED)); glitter.setScaleFunction(new InterpScale(1, 0)); glitter.setCollision(true); glitter.enableMotionCalculation(); glitter.setAcceleration(new Vec3d(0, RandUtil.nextBoolean() ? -0.0001 : 0.0001, 0)); glitter.disableRandom(); ParticleSpawner.spawn(glitter, world, new StaticInterp<>(victim.getPositionVector().add(0, victim.height / 2, 0)), 5, 0, (aFloat, particleBuilder) -> { glitter.setLifetime(RandUtil.nextInt(40, 80)); glitter.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.5f, 1f), 0f)); glitter.setAlphaFunction(new InterpFloatInOut(0.5f, 0.5f)); double radius = RandUtil.nextDouble(0, 2); double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat(); double r = radius * RandUtil.nextFloat(); double x = r * MathHelper.cos((float) theta); double z = r * MathHelper.sin((float) theta); Vec3d dest = new Vec3d(x, RandUtil.nextDouble(-radius, radius), z); glitter.setPositionOffset(dest); glitter.setMotion(new Vec3d(RandUtil.nextDouble(-0.001, 0.001), 0, RandUtil.nextDouble(-0.001, 0.001))); //glitter.setPositionFunction(new InterpSlowDown(Vec3d.ZERO, new Vec3d(0, RandUtil.nextDouble(-1, 1), 0))); //glitter.setPositionFunction(new InterpBezier3D(Vec3d.ZERO, position.subtract(dest), dest.scale(2), new Vec3d(position.x, radius, position.z))); }); }