torex tweaks

This commit is contained in:
Bob 2022-06-20 22:34:47 +02:00
parent e1b75a315e
commit 0a017e9672
2 changed files with 50 additions and 19 deletions

View File

@ -43,9 +43,13 @@ public class EntityNukeTorex extends Entity {
double range = (torusWidth - rollerSize) * 0.25; double range = (torusWidth - rollerSize) * 0.25;
if(this.ticksExisted + cloudletLife * 2 < maxAge) { 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; 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); 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); cloudlets.add(cloud);
} }
} }
@ -53,10 +57,12 @@ public class EntityNukeTorex extends Entity {
int cloudCount = ticksExisted * 3; int cloudCount = ticksExisted * 3;
if(ticksExisted < 200) { if(ticksExisted < 200) {
for(int i = 0; i < cloudCount; i++) { 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()); float rot = (float) (Math.PI * 2 * rand.nextDouble());
vec.rotateAroundY(rot); 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(); 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 { public class Cloudlet {
@ -135,17 +151,11 @@ public class EntityNukeTorex extends Entity {
this.motionY = convection.yCoord * factor + lift.yCoord * (1D - factor); this.motionY = convection.yCoord * factor + lift.yCoord * (1D - factor);
this.motionZ = convection.zCoord * factor + lift.zCoord * (1D - factor); this.motionZ = convection.zCoord * factor + lift.zCoord * (1D - factor);
if(EntityNukeTorex.this.ticksExisted > 45 * 20) { double mult = this.motionMult * getSimulationSpeed();
int timeLeft = 1600 - EntityNukeTorex.this.ticksExisted;
double scaled = Math.max((double) timeLeft / 900D, 0); this.posX += this.motionX * mult;
this.motionX *= scaled; this.posY += this.motionY * mult;
this.motionY *= scaled; this.posZ += this.motionZ * mult;
this.motionZ *= scaled;
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
this.updateColor(); this.updateColor();
} }
@ -223,7 +233,6 @@ public class EntityNukeTorex extends Entity {
dist = Math.max(dist, 1); dist = Math.max(dist, 1);
double col = 2D / dist; double col = 2D / dist;
//col *= col;
this.color = Vec3.createVectorHelper( this.color = Vec3.createVectorHelper(
Math.max(col * 2, 0.25), Math.max(col * 2, 0.25),
@ -245,6 +254,30 @@ public class EntityNukeTorex extends Entity {
prevColor.yCoord + (color.yCoord - prevColor.yCoord) * interp, prevColor.yCoord + (color.yCoord - prevColor.yCoord) * interp,
prevColor.zCoord + (color.zCoord - prevColor.zCoord) * 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 @Override

View File

@ -84,8 +84,8 @@ public class RenderTorex extends Render {
private void tessellateCloudlet(Tessellator tess, double posX, double posY, double posZ, Cloudlet cloud, float interp) { 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 alpha = cloud.getAlpha();
float scale = 1F + ((float)cloud.age / (float)EntityNukeTorex.cloudletLife) * 5; float scale = cloud.getScale();
float f1 = ActiveRenderInfo.rotationX; float f1 = ActiveRenderInfo.rotationX;
float f2 = ActiveRenderInfo.rotationZ; float f2 = ActiveRenderInfo.rotationZ;
@ -93,8 +93,6 @@ public class RenderTorex extends Render {
float f4 = ActiveRenderInfo.rotationXY; float f4 = ActiveRenderInfo.rotationXY;
float f5 = ActiveRenderInfo.rotationXZ; float f5 = ActiveRenderInfo.rotationXZ;
//Random rand = new Random((long) ((posX * 5 + posY * 25 + posZ * 125) * 1000D));
float brightness = 0.75F * cloud.colorMod; float brightness = 0.75F * cloud.colorMod;
Vec3 color = cloud.getInterpColor(interp); Vec3 color = cloud.getInterpColor(interp);
tess.setColorRGBA_F((float)color.xCoord * brightness, (float)color.yCoord * brightness, (float)color.zCoord * brightness, alpha); tess.setColorRGBA_F((float)color.xCoord * brightness, (float)color.yCoord * brightness, (float)color.zCoord * brightness, alpha);