package openonyx.features.render; import java.util.ArrayList; import java.util.List; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import openonyx.events.MovementRotation; import openonyx.features.Module; import openonyx.features.ModuleCategory; import openonyx.history.internal.BooleanSetting; import openonyx.history.internal.ColorSetting; import openonyx.history.internal.EnumSetting; import openonyx.history.internal.NumberSetting; import openonyx.render.group_i.ChinaHatRenderer; import openonyx.render.group_i.ChinaHatStyle; import openonyx.render.group_i.HatColorMode; import openonyx.render.group_i.HatPose; public final class ChinaHat extends Module { private static final float A = 1.5F; private final ChinaHatRenderer chinaHatRenderer; public NumberSetting trailLength; public NumberSetting offset; private float J; public ColorSetting secondColor; private static final float c = 0.22F; private long a; public NumberSetting colorSpeed; public NumberSetting height; public BooleanSetting glow; private float L; public BooleanSetting throughWalls; public ColorSetting color; public NumberSetting tilt; public NumberSetting opacity; public NumberSetting radius = new NumberSetting("Radius", 0.65, 0.2, 3.0, 0.05).describe("How wide the brim sits"); public EnumSetting colors; private static final float i = (float) (Math.PI * 2); public BooleanSetting trail; private final List hatPoses; public NumberSetting spinSpeed; private void h() { ChinaHat chinaHat1 = this; long l = System.nanoTime(); if (chinaHat1.a == 0L) { chinaHat1.a = l; } else { float f = Math.min((float)(l - chinaHat1.a) / 1.0E9F, 0.25F); chinaHat1.a = l; chinaHat1.L = (chinaHat1.L + (float)Math.toRadians(chinaHat1.spinSpeed.getValue()) * f) % (float) (Math.PI * 2); chinaHat1.J = (chinaHat1.J + (float)Math.toRadians(chinaHat1.colorSpeed.getValue()) * f) % (float) (Math.PI * 2); } } public ChinaHat() { super("ChinaHat", "Floats a conical hat over your head", ModuleCategory.RENDER); this.height = new NumberSetting("Height", 0.35, 0.05, 1.5, 0.05).describe("How tall the cone stands"); this.offset = new NumberSetting("Offset", -0.02, -0.5, 1.5, 0.02).describe("How far above the head the brim sits"); this.tilt = new NumberSetting("Tilt", 100.0, 0.0, 100.0, 5.0).withSuffix("%").describe("How much of the head's pitch the hat takes on"); this.colors = new EnumSetting<>("Colors", HatColorMode.STATIC).describe("Hold one colour, blend two around the hat, or walk the hue right round it"); this.color = new ColorSetting("Color", -10178561).D(); this.secondColor = new ColorSetting("Second color", -4949761) .visibleWhen(this.colors, hatColorMode -> hatColorMode == HatColorMode.GRADIENT) .describe("The colour the first one blends into"); this.colorSpeed = new NumberSetting("Color speed", 40.0, 0.0, 360.0, 5.0) .withSuffix("°/s") .visibleWhen(this.colors, hatColorMode -> hatColorMode != HatColorMode.STATIC) .describe("How fast the colours travel around the hat - zero holds them still"); this.opacity = new NumberSetting("Opacity", 90.0, 5.0, 100.0, 1.0).withSuffix("%").describe("Overall opacity of the hat"); this.spinSpeed = new NumberSetting("Spin speed", 65.0, 0.0, 360.0, 5.0).withSuffix("°/s").describe("How fast the line travels around the hat"); this.glow = new BooleanSetting("Glow", true).describe("Soft halo right on the rim"); this.trail = new BooleanSetting("Trail", true).describe("Line sweeping around the hat, and the fading wake behind it"); this.trailLength = new NumberSetting("Trail length", 350.0, 20.0, 360.0, 10.0) .withSuffix("°") .describe("How far back the wake reaches") .visibleWhen(this.trail); this.throughWalls = new BooleanSetting("Through walls", false); this.chinaHatRenderer = new ChinaHatRenderer(); this.hatPoses = new ArrayList<>(); } public void d(float f) { if (this.isEnabled() && mc.theWorld != null && mc.thePlayer != null) { this.h(); this.hatPoses.clear(); if (mc.gameSettings.thirdPersonView != 0 && mc.thePlayer.isEntityAlive()) { this.L(f); } this.chinaHatRenderer.L(f, this.hatPoses, this.L()); } } private ChinaHatStyle L() { return new ChinaHatStyle( this.radius.getFloat(), this.height.getFloat(), this.colors.getValue(), this.color.getOpaque(), this.secondColor.getOpaque(), this.J, this.opacity.getFloat() / 100.0F, this.glow.isEnabled(), this.trail.isEnabled(), (float)Math.toRadians(this.trailLength.getValue()), this.L, this.throughWalls.isEnabled() ); } @Override protected void onEnable() { this.a = 0L; } private float d(float f) { return MovementRotation.L(mc.thePlayer) ? MovementRotation.d(f) : mc.thePlayer.prevRotationYawHead + MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYawHead - mc.thePlayer.prevRotationYawHead) * f; } private float L(float f) { return MovementRotation.L(mc.thePlayer) ? MovementRotation.L(f) : mc.thePlayer.prevRotationPitch + MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationPitch - mc.thePlayer.prevRotationPitch) * f; } private void L(float f) { ChinaHat chinaHat1 = this; EntityPlayerSP entityPlayerSP = mc.thePlayer; double d = mc.thePlayer.prevPosY + (entityPlayerSP.posY - entityPlayerSP.prevPosY) * f + 1.5; if (entityPlayerSP.isSneaking()) { d -= 0.22F; } Vec3 vec3 = new Vec3( entityPlayerSP.prevPosX + (entityPlayerSP.posX - entityPlayerSP.prevPosX) * f, d, entityPlayerSP.prevPosZ + (entityPlayerSP.posZ - entityPlayerSP.prevPosZ) * f ); float g = entityPlayerSP.height + chinaHat1.offset.getFloat() - 1.5F; chinaHat1.hatPoses.add(new HatPose(vec3, g, chinaHat1.d(f), chinaHat1.L(f) * (chinaHat1.tilt.getFloat() / 100.0F), 0.0F)); } @Override protected void onDisable() { this.hatPoses.clear(); this.chinaHatRenderer.d(); } }