From 0a017e9672d52801918121f56d39f4be535cf02b Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 20 Jun 2022 22:34:47 +0200 Subject: [PATCH] torex tweaks --- .../hbm/entity/effect/EntityNukeTorex.java | 63 ++++++++++++++----- .../hbm/render/entity/effect/RenderTorex.java | 6 +- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java b/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java index 4ea9d3c6d..3ad54fc6e 100644 --- a/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java +++ b/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java @@ -43,9 +43,13 @@ public class EntityNukeTorex extends Entity { double range = (torusWidth - rollerSize) * 0.25; if(this.ticksExisted + cloudletLife * 2 < maxAge) { - for(int i = 0; i < 20; i++) { + + int toSpawn = (int) Math.ceil(10 * getSimulationSpeed()); + + for(int i = 0; i < toSpawn; i++) { double y = posY + rand.nextGaussian() - 3; //this.ticksExisted < 60 ? this.posY + this.coreHeight : posY + rand.nextGaussian() - 3; Cloudlet cloud = new Cloudlet(posX + rand.nextGaussian() * range, y, posZ + rand.nextGaussian() * range, (float)(rand.nextDouble() * 2D * Math.PI), 0); + cloud.setScale(1F + this.ticksExisted * 0.001F, 5F); cloudlets.add(cloud); } } @@ -53,10 +57,12 @@ public class EntityNukeTorex extends Entity { int cloudCount = ticksExisted * 3; if(ticksExisted < 200) { for(int i = 0; i < cloudCount; i++) { - Vec3 vec = Vec3.createVectorHelper(ticksExisted + rand.nextDouble(), 0, 0); + Vec3 vec = Vec3.createVectorHelper((ticksExisted + rand.nextDouble()) * 2, 0, 0); float rot = (float) (Math.PI * 2 * rand.nextDouble()); vec.rotateAroundY(rot); - this.cloudlets.add(new Cloudlet(vec.xCoord + posX, worldObj.getHeightValue((int) (vec.xCoord + posX) + 2, (int) (vec.zCoord + posZ)), vec.zCoord + posZ, rot, 0)); + this.cloudlets.add(new Cloudlet(vec.xCoord + posX, worldObj.getHeightValue((int) (vec.xCoord + posX) + 1, (int) (vec.zCoord + posZ)), vec.zCoord + posZ, rot, 0) + .setScale(5F, 2F) + .setMotion(0)); } } @@ -79,6 +85,16 @@ public class EntityNukeTorex extends Entity { this.setDead(); } } + + public double getSimulationSpeed() { + + if(EntityNukeTorex.this.ticksExisted > 45 * 20) { + int timeLeft = 1600 - EntityNukeTorex.this.ticksExisted; + return MathHelper.clamp_double((double) timeLeft / 900D, 0, 1); + } + + return 1.0D; + } public class Cloudlet { @@ -135,17 +151,11 @@ public class EntityNukeTorex extends Entity { this.motionY = convection.yCoord * factor + lift.yCoord * (1D - factor); this.motionZ = convection.zCoord * factor + lift.zCoord * (1D - factor); - if(EntityNukeTorex.this.ticksExisted > 45 * 20) { - int timeLeft = 1600 - EntityNukeTorex.this.ticksExisted; - double scaled = Math.max((double) timeLeft / 900D, 0); - this.motionX *= scaled; - this.motionY *= scaled; - this.motionZ *= scaled; - } - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; + double mult = this.motionMult * getSimulationSpeed(); + + this.posX += this.motionX * mult; + this.posY += this.motionY * mult; + this.posZ += this.motionZ * mult; this.updateColor(); } @@ -223,7 +233,6 @@ public class EntityNukeTorex extends Entity { dist = Math.max(dist, 1); double col = 2D / dist; - //col *= col; this.color = Vec3.createVectorHelper( Math.max(col * 2, 0.25), @@ -245,6 +254,30 @@ public class EntityNukeTorex extends Entity { prevColor.yCoord + (color.yCoord - prevColor.yCoord) * interp, prevColor.zCoord + (color.zCoord - prevColor.zCoord) * interp); } + + public float getAlpha() { + return 1F - ((float)age / (float)cloudletLife); + } + + private float startingScale = 1; + private float growingScale = 5F; + + public float getScale() { + return startingScale + ((float)age / (float)cloudletLife) * growingScale; + } + + public Cloudlet setScale(float start, float grow) { + this.startingScale = start; + this.growingScale = grow; + return this; + } + + private double motionMult = 1F; + + public Cloudlet setMotion(double mult) { + this.motionMult = mult; + return this; + } } @Override diff --git a/src/main/java/com/hbm/render/entity/effect/RenderTorex.java b/src/main/java/com/hbm/render/entity/effect/RenderTorex.java index 3fc1195ed..661b57773 100644 --- a/src/main/java/com/hbm/render/entity/effect/RenderTorex.java +++ b/src/main/java/com/hbm/render/entity/effect/RenderTorex.java @@ -84,8 +84,8 @@ public class RenderTorex extends Render { private void tessellateCloudlet(Tessellator tess, double posX, double posY, double posZ, Cloudlet cloud, float interp) { - float alpha = 1F - ((float)cloud.age / (float)EntityNukeTorex.cloudletLife); - float scale = 1F + ((float)cloud.age / (float)EntityNukeTorex.cloudletLife) * 5; + float alpha = cloud.getAlpha(); + float scale = cloud.getScale(); float f1 = ActiveRenderInfo.rotationX; float f2 = ActiveRenderInfo.rotationZ; @@ -93,8 +93,6 @@ public class RenderTorex extends Render { float f4 = ActiveRenderInfo.rotationXY; float f5 = ActiveRenderInfo.rotationXZ; - //Random rand = new Random((long) ((posX * 5 + posY * 25 + posZ * 125) * 1000D)); - float brightness = 0.75F * cloud.colorMod; Vec3 color = cloud.getInterpColor(interp); tess.setColorRGBA_F((float)color.xCoord * brightness, (float)color.yCoord * brightness, (float)color.zCoord * brightness, alpha);