下面列出了怎么用net.minecraft.util.math.MathHelper的API类实例代码及写法,或者点击链接到github查看源代码。
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++;
}
}
}
}
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;
}
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);
}
}
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();
}
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;
}
@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);
}
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);
}
@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);
}
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;
}
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();
}
}
@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;
}
}
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;
}
@Override
public boolean generate(ServerWorldAccess serverWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, GCOreFeatureConfig oreFeatureConfig) {
float f = random.nextFloat() * 3.1415927F;
float g = (float) oreFeatureConfig.size / 8.0F;
int i = MathHelper.ceil(((float) oreFeatureConfig.size / 16.0F * 2.0F + 1.0F) / 2.0F);
double d = (float) blockPos.getX() + MathHelper.sin(f) * g;
double e = (float) blockPos.getX() - MathHelper.sin(f) * g;
double h = (float) blockPos.getZ() + MathHelper.cos(f) * g;
double j = (float) blockPos.getZ() - MathHelper.cos(f) * g;
double l = blockPos.getY() + random.nextInt(3) - 2;
double m = blockPos.getY() + random.nextInt(3) - 2;
int n = blockPos.getX() - MathHelper.ceil(g) - i;
int o = blockPos.getY() - 2 - i;
int p = blockPos.getZ() - MathHelper.ceil(g) - i;
int q = 2 * (MathHelper.ceil(g) + i);
int r = 2 * (2 + i);
for (int s = n; s <= n + q; ++s) {
for (int t = p; t <= p + q; ++t) {
if (o <= serverWorldAccess.getTopY(Heightmap.Type.OCEAN_FLOOR_WG, s, t)) {
return this.generateVeinPart(serverWorldAccess, random, oreFeatureConfig, d, e, h, j, l, m, n, o, p, q, r);
}
}
}
return false;
}
@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)));
});
}
private float limitAngleChange(float current, float intended,
float maxChange)
{
float change = MathHelper.wrapDegrees(intended - current);
change = MathHelper.clamp(change, -maxChange, maxChange);
return MathHelper.wrapDegrees(current + change);
}
@Override
public void onTick() {
setViewAngles(
MathHelper.clamp(
getLocalPlayer().rotationPitch + MathHelper.cos(ang += 0.1f), -90.f, 90.f),
getLocalPlayer().rotationYaw + 1.8f);
}
/**
* 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_) {
ocelotHead.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI);
ocelotHead.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI);
if (field_78163_i != 3) {
ocelotBody.rotateAngleX = ((float) Math.PI / 2F);
if (field_78163_i == 2) {
ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.0F * p_78087_2_;
ocelotBackRightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + 0.3F) * 1.0F * p_78087_2_;
ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float) Math.PI + 0.3F) * 1.0F * p_78087_2_;
ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float) Math.PI) * 1.0F * p_78087_2_;
ocelotTail2.rotateAngleX = 1.7278761F + ((float) Math.PI / 10F) * MathHelper.cos(p_78087_1_) * p_78087_2_;
} else {
ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.0F * p_78087_2_;
ocelotBackRightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float) Math.PI) * 1.0F * p_78087_2_;
ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float) Math.PI) * 1.0F * p_78087_2_;
ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.0F * p_78087_2_;
if (field_78163_i == 1) {
ocelotTail2.rotateAngleX = 1.7278761F + ((float) Math.PI / 4F) * MathHelper.cos(p_78087_1_) * p_78087_2_;
} else {
ocelotTail2.rotateAngleX = 1.7278761F + 0.47123894F * MathHelper.cos(p_78087_1_) * p_78087_2_;
}
}
}
}
/**
* Clamps the Quad inside the box.
*
* @param bb The box.
*/
public void clamp(AxisAlignedBB bb) {
for (Vertex vertex : vertices) {
float[] vec = vertex.vec;
vec[0] = (float) MathHelper.clamp(vec[0], bb.minX, bb.maxX);
vec[1] = (float) MathHelper.clamp(vec[1], bb.minY, bb.maxY);
vec[2] = (float) MathHelper.clamp(vec[2], bb.minZ, bb.maxZ);
}
calculateOrientation(true);
}
@Override
public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
float rotation = model.getAttributes().isSleeping ? 0 : MathHelper.sin(ticks * 0.536f) / 4;
tailBase.pitch = TAIL_ROTX + rotation;
tailTip.pitch = rotation;
tailFins.pitch = rotation - TAIL_ROTX;
}
private boolean move(int amount, boolean playSound)
{
this.position = MathHelper.clamp(this.position + amount, 0, this.positionMax);
this.parent.scrollbarAction(this.id, ScrollbarAction.MOVE, -1);
if (playSound)
{
this.playPressSound();
}
return true;
}
@Override
public void render(TileManaMagnet te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
if (te.manaOrb != null) {
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5);
GlStateManager.translate(0, MathHelper.sin(ClientTickHandler.getTicks()) / 2.0, 0);
GlStateManager.disableRescaleNormal();
{
GlStateManager.enableRescaleNormal();
GlStateManager.disableCull();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableLighting();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().getTextureManager().bindTexture(manaPearlCubeTexture);
TileOrbHolderRenderer.renderCube(0.1, Color.WHITE);
GlStateManager.disableRescaleNormal();
}
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
private static float getSpeedModifier(ItemStack stack) {
if (UpgradeTools.containsUpgrade(stack, Upgrade.EFFICIENCY_1)) {
double efficiency = UpgradeTools.getUpgradeFromGadget(stack, Upgrade.EFFICIENCY_1).get().getTier() / 5f;
double speedModifier = MathHelper.lerp(efficiency, 0.02, 0.05);
return (float) -speedModifier;
} else {
return -0.02f;
}
}
@Override
public float getSunBrightness(float partialTicks) {
float atmosphere = getAtmosphereDensity(new BlockPos(0,0,0));
Math.abs(1-atmosphere);
//calculateCelestialAngle(p_76563_1_, p_76563_3_)
float f1 = world.getCelestialAngle(partialTicks);
float f2 = 1.0F - (MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.2F) - atmosphere/4f;
if (f2 < 0.0F)
{
f2 = 0.0F ;
}
if (f2 > 1.0F)
{
f2 = 1.0F;
}
f2 = 1.0F - f2;
//Eclipse handling
if(this.world.isRemote) {
DimensionProperties properties = getDimensionProperties(Minecraft.getMinecraft().player.getPosition());
if(properties.isMoon()) {
f2 = eclipseValue(properties, f2, partialTicks);
}
else {
for(int i : properties.getChildPlanets()) {
DimensionProperties childProps = DimensionManager.getInstance().getDimensionProperties(i);
f2 = eclipseValue(childProps, f2, partialTicks);
}
}
}
return f2*super.getSunBrightness(partialTicks);
}
public CapManagerBuilder setBurnout(double burnout) {
if (cap == null) return this;
double clamped = MathHelper.clamp(burnout, 0, getMaxBurnout());
if (cap.getBurnout() != clamped) {
cap.setBurnout(clamped);
somethingChanged = true;
}
return this;
}
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Vec3d position = spell.getTarget(world);
if (position == null) return;
double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);
double maxPotency = spellRing.getModule() != null ? spellRing.getModule().getAttributeRanges().get(AttributeRegistry.POTENCY).max : 1;
ParticleBuilder glitter = new ParticleBuilder(0);
glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 10, 10, (aFloat, particleBuilder) -> {
particleBuilder.setScale((float) RandUtil.nextDouble(0.3, 1));
particleBuilder.setAlphaFunction(new InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
particleBuilder.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
particleBuilder.setLifetime(RandUtil.nextInt(20, 30));
particleBuilder.setScaleFunction(new InterpScale(1, 0));
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);
particleBuilder.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z).normalize().scale(RandUtil.nextFloat((float) ((maxPotency - potency) / maxPotency / 10.0))));
particleBuilder.addMotion(particleBuilder.getPositionOffset().scale(-1.0 / RandUtil.nextDouble(10, 30)));
});
}
private void changeInventorySize(int changeAmount)
{
int newSize = MathHelper.clamp(this.getSlotCount() + changeAmount, 1, MAX_LENGTH_ADVANCED);
// Shrinking the inventory, only allowed if there are no items in the slots-to-be-removed
if (changeAmount < 0)
{
int changeFinal = 0;
for (int slot = this.getSlotCount() - 1; slot >= newSize && slot >= 1; slot--)
{
if (this.itemHandlerDrawbridge.getStackInSlot(slot).isEmpty())
{
changeFinal--;
}
else
{
break;
}
}
newSize = MathHelper.clamp(this.getSlotCount() + changeFinal, 1, MAX_LENGTH_ADVANCED);
}
if (newSize >= 1 && newSize <= MAX_LENGTH_ADVANCED)
{
this.setMaxLength(newSize);
}
}
public void setStorageTier(World world, int tier)
{
this.chestTier = MathHelper.clamp(tier, 0, MAX_TIER);
this.invSize = INV_SIZES[this.chestTier];
this.initStorage(this.invSize, world.isRemote);
}
@Redirect(method = "createRunningParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;floor(D)I", ordinal = 2))
public int runningParticlesThirdFloor(double d) {
if (searchVector == null) {
return MathHelper.floor(d);
} else {
return MathHelper.floor(searchVector.Z);
}
}
@Override
public void onModuleUpdated(ModuleBase module) {
if(module == textBox) {
if(textBox.getText().isEmpty())
minStackTransferSize = 1;
else
minStackTransferSize = MathHelper.clamp(Integer.parseInt(textBox.getText()),1, 64);
PacketHandler.sendToServer(new PacketMachine(this, (byte)4));
}
}
@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);
}
}