diff --git a/src/openonyx/render/group_j/ParticleMath.java b/src/openonyx/render/group_j/ParticleMath.java new file mode 100644 index 0000000..f80f34f --- /dev/null +++ b/src/openonyx/render/group_j/ParticleMath.java @@ -0,0 +1,46 @@ +package openonyx.render.group_j; + +import openonyx.theme.internal.ColorUtils; + +public final class ParticleMath { + public static final float H = 0.5019608F; + private static final long e = 500L; + + public static double L(double d) { + return d * 0.01; + } + + public static float L(long l, long m) { + float f; + if (l < 500L) { + f = (float)l / 500.0F; + } else if (l < m) { + f = 1.0F; + } else if (l < m + 500L) { + f = 1.0F - (float)(l - m) / 500.0F; + } else { + f = 0.0F; + } + + return 0.5019608F * Math.clamp(f, 0.0F, 1.0F); + } + + private static int L(int i, int j, float f) { + return Math.round(i + (j - i) * f); + } + + public static long L(long l, double d) { + return Math.round(l / Math.max(0.01, d)); + } + + public static int L(int i, int j, int k, long l) { + int m; + float f = ((m = (int)Math.floorMod(l / 10L + k * 50L, 360L)) >= 180 ? 360 - m : m) * 2 / 360.0F; + return ColorUtils.argb( + 255, L(ColorUtils.red(i), ColorUtils.red(j), f), L(ColorUtils.green(i), ColorUtils.green(j), f), L(ColorUtils.blue(i), ColorUtils.blue(j), f) + ); + } + + private ParticleMath() { + } +} diff --git a/src/openonyx/render/group_j/WorldParticle.java b/src/openonyx/render/group_j/WorldParticle.java new file mode 100644 index 0000000..4e4a5a2 --- /dev/null +++ b/src/openonyx/render/group_j/WorldParticle.java @@ -0,0 +1,198 @@ +package openonyx.render.group_j; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockBasePressurePlate; +import net.minecraft.block.BlockBush; +import net.minecraft.block.BlockButton; +import net.minecraft.block.BlockCarpet; +import net.minecraft.block.BlockLever; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.BlockTorch; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import openonyx.features.render.Particles; +import openonyx.theme.internal.ColorUtils; + +public final class WorldParticle { + private static final float c = 0.1F; + private double a; + private boolean k; + private final int g; + private final int M; + private final Particles particles; + private final WorldParticleMode worldParticleMode; + private double m; + private final World world; + private double l; + private double I; + private float d; + private static final double i = 1.0E-7; + private final long f = System.currentTimeMillis(); + private double H; + private double e; + + public void d() { + if (this.k) { + if (!this.d()) { + this.L(); + } else { + long lx; + if ((lx = this.L()) >= this.worldParticleMode.f) { + this.L(); + } else { + WorldParticle worldParticle1; + if (this.particles.physics.isEnabled()) { + this.L(this.particles.physicsSpeed.getValue()); + worldParticle1 = this; + } else { + this.l = this.l + this.H; + worldParticle1 = this; + this.I = this.I + this.a; + this.e = this.e + this.m; + } + + worldParticle1.d = ParticleMath.L(lx, this.worldParticleMode.H); + } + } + } + } + + public void L() { + this.k = false; + } + + private boolean L(double d, double e, double f) { + BlockPos blockPos = new BlockPos(dx, ex, fx); + return !this.world.isBlockLoaded(blockPos) ? false : this.L(this.world.getBlockState(blockPos).getBlock()); + } + + private boolean L(Block block) { + return !(block instanceof BlockAir) + && !(block instanceof BlockBush) + && !(block instanceof BlockButton) + && !(block instanceof BlockTorch) + && !(block instanceof BlockLever) + && !(block instanceof BlockBasePressurePlate) + && !(block instanceof BlockCarpet) + && !(block instanceof BlockLiquid); + } + + public WorldParticle(Particles particles, World world, WorldParticleMode worldParticleMode, int i, int j, Vec3 vec3, Vec3 vec31) { + this.k = true; + this.particles = particlesx; + this.world = worldx; + this.worldParticleMode = worldParticleModex; + this.g = ix; + this.M = j; + this.l = vec3.xCoord; + this.I = vec3.yCoord; + this.e = vec3.zCoord; + this.H = ParticleMath.L(vec31.xCoord); + this.a = ParticleMath.L(vec31.yCoord); + this.m = ParticleMath.L(vec31.zCoord); + } + + private long d() { + return Math.max(0L, System.currentTimeMillis() - this.f); + } + + private boolean d() { + return this.particles != null && this.particles.isEnabled() && Particles.mc.theWorld == this.world; + } + + public boolean L() { + return this.k; + } + + private double L(double d, double e, double f) { + WorldParticle worldParticle1 = this; + BlockPos blockPos = new BlockPos(dx, ex - 1.0E-7, fx); + if (!worldParticle1.world.isBlockLoaded(blockPos)) { + return Double.NaN; + } else { + IBlockState iBlockState; + if (!worldParticle1.L((iBlockState = worldParticle1.world.getBlockState(blockPos)).getBlock())) { + return Double.NaN; + } else { + AxisAlignedBB axisAlignedBB; + if ((axisAlignedBB = iBlockState.getBlock().getCollisionBoundingBox(worldParticle1.world, blockPos, iBlockState)) == null) { + return Double.NaN; + } else if (dx + 1.0E-7 < axisAlignedBB.minX + || dx - 1.0E-7 > axisAlignedBB.maxX + || fx + 1.0E-7 < axisAlignedBB.minZ + || fx - 1.0E-7 > axisAlignedBB.maxZ) { + return Double.NaN; + } else { + return ex <= axisAlignedBB.maxY + 1.0E-7 ? axisAlignedBB.maxY : Double.NaN; + } + } + } + } + + private long L() { + return ParticleMath.L(this.d(), this.particles.duration.getValue()); + } + + public void L(WorldRenderer worldRenderer, Vec3 vec3, float f, float g, float h, float i, float j) { + WorldParticle worldParticle1 = this; + if (worldParticle1.k && !(worldParticle1.d <= 0.0F)) { + int n = worldParticle1.particles.L(worldParticle1.g, worldParticle1.M); + int kx = Math.round((float)Math.pow(Math.clamp(worldParticle1.d, 0.0F, 1.0F), 0.72) * 255.0F); + float lx = 0.1F * worldParticle1.particles.size.getFloat(); + double dx = worldParticle1.l - vec3.xCoord; + double ex = worldParticle1.I - vec3.yCoord; + double mx = worldParticle1.e - vec3.zCoord; + L(worldRenderer, dx, ex, mx, lx, ColorUtils.red(n), ColorUtils.green(n), ColorUtils.blue(n), kx, fx, gx, h, ix, j); + L(worldRenderer, dx, ex, mx, lx * 0.5F, 255, 255, 255, kx, fx, gx, h, ix, j); + } + } + + private void L(double d) { + WorldParticle worldParticle1 = this; + if (worldParticle1.L(worldParticle1.l, worldParticle1.I, worldParticle1.e + worldParticle1.m * dx)) { + worldParticle1.m *= -0.8; + } + + double ex = 0.1F * worldParticle1.particles.size.getValue() + 1.0E-7; + double fx = worldParticle1.a <= 0.0 ? worldParticle1.L(worldParticle1.l, worldParticle1.I + worldParticle1.a * dx - ex, worldParticle1.e) : Double.NaN; + boolean bl = worldParticle1.a <= 0.0 + ? Double.isFinite(fx) + : worldParticle1.L(worldParticle1.l, worldParticle1.I + worldParticle1.a * dx, worldParticle1.e); + if (bl) { + worldParticle1.H *= 0.999; + worldParticle1.m *= 0.999; + worldParticle1.a *= -0.7; + } + + if (worldParticle1.L(worldParticle1.l + worldParticle1.H * dx, worldParticle1.I, worldParticle1.e)) { + worldParticle1.H *= -0.8; + } + + double gx = worldParticle1.I + worldParticle1.a * dx; + if (Double.isFinite(fx)) { + gx = Math.max(gx, fx + ex); + } + + worldParticle1.l = worldParticle1.l + worldParticle1.H * dx; + worldParticle1.I = gx; + worldParticle1.e = worldParticle1.e + worldParticle1.m * dx; + ex = Math.pow(0.999999, dx); + worldParticle1.H /= ex; + worldParticle1.a -= 5.0E-5 * dx; + worldParticle1.m /= ex; + } + + private static void L( + WorldRenderer worldRenderer, double d, double e, double f, float g, int i, int j, int k, int l, float h, float m, float n, float o, float p + ) { + worldRenderer.pos(dx - h * gx - o * gx, ex - mx * gx, fx - n * gx - p * gx).tex(0.0, 0.0).color(ix, j, kx, lx).endVertex(); + worldRenderer.pos(dx - h * gx + o * gx, ex + mx * gx, fx - n * gx + p * gx).tex(0.0, 1.0).color(ix, j, kx, lx).endVertex(); + worldRenderer.pos(dx + h * gx + o * gx, ex + mx * gx, fx + n * gx + p * gx).tex(1.0, 1.0).color(ix, j, kx, lx).endVertex(); + worldRenderer.pos(dx + h * gx - o * gx, ex - mx * gx, fx + n * gx - p * gx).tex(1.0, 0.0).color(ix, j, kx, lx).endVertex(); + } +} diff --git a/src/openonyx/render/group_j/WorldParticleMode.java b/src/openonyx/render/group_j/WorldParticleMode.java new file mode 100644 index 0000000..85ff29a --- /dev/null +++ b/src/openonyx/render/group_j/WorldParticleMode.java @@ -0,0 +1,22 @@ +package openonyx.render.group_j; + +public enum WorldParticleMode { + WALKING(3500L, 3000L), + ATTACK(5000L, 2000L); + + private final long f; + private final long H; + + WorldParticleMode(long l, long m) { + this.f = l; + this.H = m; + } + + private static WorldParticleMode[] L() { + WorldParticleMode[] worldParticleModes = new WorldParticleMode[2]; + boolean bl = true; + worldParticleModes[0] = ATTACK; + worldParticleModes[1] = WALKING; + return worldParticleModes; + } +}