more particle improvements

This commit is contained in:
Sen 2025-07-10 18:24:08 +02:00
parent 28d6850668
commit d95a3f8b11
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
58 changed files with 266 additions and 444 deletions

View file

@ -1846,42 +1846,13 @@ public class ClientPlayer implements IClientPlayer
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
if (packetIn.getParticleCount() == 0)
try
{
double d0 = (double)(packetIn.getParticleSpeed() * packetIn.getXOffset());
double d2 = (double)(packetIn.getParticleSpeed() * packetIn.getYOffset());
double d4 = (double)(packetIn.getParticleSpeed() * packetIn.getZOffset());
try
{
this.world.spawnParticle(packetIn.getParticleType(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), d0, d2, d4, packetIn.getParticleArg());
}
catch (Throwable var17)
{
Log.RENDER.warn("Konnte Partikel-Effekt " + packetIn.getParticleType() + " nicht erzeugen");
}
this.world.spawnParticle(packetIn.getParticleType(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), packetIn.getParticleArg());
}
else
catch (Throwable var17)
{
for (int i = 0; i < packetIn.getParticleCount(); ++i)
{
double d1 = this.rand.gaussian() * (double)packetIn.getXOffset();
double d3 = this.rand.gaussian() * (double)packetIn.getYOffset();
double d5 = this.rand.gaussian() * (double)packetIn.getZOffset();
double d6 = this.rand.gaussian() * (double)packetIn.getParticleSpeed();
double d7 = this.rand.gaussian() * (double)packetIn.getParticleSpeed();
double d8 = this.rand.gaussian() * (double)packetIn.getParticleSpeed();
try
{
this.world.spawnParticle(packetIn.getParticleType(), packetIn.getXCoordinate() + d1, packetIn.getYCoordinate() + d3, packetIn.getZCoordinate() + d5, d6, d7, d8, packetIn.getParticleArg());
}
catch (Throwable var16)
{
Log.RENDER.warn("Konnte Partikel-Effekt " + packetIn.getParticleType() + " nicht erzeugen");
return;
}
}
Log.RENDER.warn("Konnte Partikel-Effekt " + packetIn.getParticleType() + " nicht erzeugen");
}
}

View file

@ -29,18 +29,13 @@ import common.world.State;
import common.world.World;
public class EffectRenderer {
private abstract class Effect {
protected int age;
protected int lifetime;
public abstract boolean onUpdate();
public abstract void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ);
public abstract int getLayer();
private interface Effect {
boolean onUpdate();
void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ);
int getLayer();
}
private abstract class Moveable extends Effect {
private abstract class Moveable implements Effect {
protected double prevX;
protected double prevY;
protected double prevZ;
@ -51,6 +46,8 @@ public class EffectRenderer {
protected double motionY;
protected double motionZ;
protected int age;
protected int lifetime;
protected float gravity;
protected Moveable(double posXIn, double posYIn, double posZIn) {
@ -104,25 +101,25 @@ public class EffectRenderer {
public final void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ) {
this.setScale(partial);
float f = (float)this.textureU / 8.0F;
float f1 = f + 1.0f / 8.0f;
float f2 = (float)this.textureV / 4.0F;
float f3 = f2 + 1.0f / 4.0f;
float f4 = 0.1F * this.scale;
float f5 = (float)(this.prevX + (this.posX - this.prevX) * (double)partial - interpPosX);
float f6 = (float)(this.prevY + (this.posY - this.prevY) * (double)partial - interpPosY);
float f7 = (float)(this.prevZ + (this.posZ - this.prevZ) * (double)partial - interpPosZ);
int i = this.getBrightness(partial);
int j = i >> 16 & 65535;
int k = i & 65535;
rb.pos((double)(f5 - rotX * f4 - rotXY * f4), (double)(f6 - rotZ * f4), (double)(f7 - rotYZ * f4 - rotXZ * f4))
.tex((double)f1, (double)f3).color(this.red, this.green, this.blue, 1.0f).lightmap(j, k).endVertex();
rb.pos((double)(f5 - rotX * f4 + rotXY * f4), (double)(f6 + rotZ * f4), (double)(f7 - rotYZ * f4 + rotXZ * f4))
.tex((double)f1, (double)f2).color(this.red, this.green, this.blue, 1.0f).lightmap(j, k).endVertex();
rb.pos((double)(f5 + rotX * f4 + rotXY * f4), (double)(f6 + rotZ * f4), (double)(f7 + rotYZ * f4 + rotXZ * f4)).tex((double)f, (double)f2)
.color(this.red, this.green, this.blue, 1.0f).lightmap(j, k).endVertex();
rb.pos((double)(f5 + rotX * f4 - rotXY * f4), (double)(f6 - rotZ * f4), (double)(f7 + rotYZ * f4 - rotXZ * f4)).tex((double)f, (double)f3)
.color(this.red, this.green, this.blue, 1.0f).lightmap(j, k).endVertex();
float u1 = (float)this.textureU / 8.0F;
float u2 = u1 + 1.0f / 8.0f;
float v1 = (float)this.textureV / 4.0F;
float v2 = v1 + 1.0f / 4.0f;
float scale = 0.1F * this.scale;
float x = (float)(this.prevX + (this.posX - this.prevX) * (double)partial - interpPosX);
float y = (float)(this.prevY + (this.posY - this.prevY) * (double)partial - interpPosY);
float z = (float)(this.prevZ + (this.posZ - this.prevZ) * (double)partial - interpPosZ);
int light = this.getBrightness(partial);
int sky = light >> 16 & 65535;
int block = light & 65535;
rb.pos((double)(x - rotX * scale - rotXY * scale), (double)(y - rotZ * scale), (double)(z - rotYZ * scale - rotXZ * scale))
.tex((double)u2, (double)v2).color(this.red, this.green, this.blue, 1.0f).lightmap(sky, block).endVertex();
rb.pos((double)(x - rotX * scale + rotXY * scale), (double)(y + rotZ * scale), (double)(z - rotYZ * scale + rotXZ * scale))
.tex((double)u2, (double)v1).color(this.red, this.green, this.blue, 1.0f).lightmap(sky, block).endVertex();
rb.pos((double)(x + rotX * scale + rotXY * scale), (double)(y + rotZ * scale), (double)(z + rotYZ * scale + rotXZ * scale)).tex((double)u1, (double)v1)
.color(this.red, this.green, this.blue, 1.0f).lightmap(sky, block).endVertex();
rb.pos((double)(x + rotX * scale - rotXY * scale), (double)(y - rotZ * scale), (double)(z + rotYZ * scale - rotXZ * scale)).tex((double)u1, (double)v2)
.color(this.red, this.green, this.blue, 1.0f).lightmap(sky, block).endVertex();
}
public final int getLayer() {
@ -138,9 +135,9 @@ public class EffectRenderer {
private class Aura extends Particle {
private final boolean fullBright;
protected Aura(double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double speedIn, boolean fullBright,
protected Aura(double xCoordIn, double yCoordIn, double zCoordIn, boolean fullBright,
int texture) {
super(xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, speedIn);
super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
float f = texture != 0 ? 1.0f : rng.floatv() * 0.1F + 0.2F;
this.red = f;
this.green = f;
@ -177,14 +174,14 @@ public class EffectRenderer {
private class Crit extends Particle {
private final float baseScale;
protected Crit(double xCoordIn, double yCoordIn, double zCoordIn, double p_i46285_8_, double p_i46285_10_, double p_i46285_12_) {
protected Crit(double xCoordIn, double yCoordIn, double zCoordIn) {
super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
this.motionX *= 0.10000000149011612D;
this.motionY *= 0.10000000149011612D;
this.motionZ *= 0.10000000149011612D;
this.motionX += p_i46285_8_ * 0.4D;
this.motionY += p_i46285_10_ * 0.4D;
this.motionZ += p_i46285_12_ * 0.4D;
this.motionX += (double)(rng.floatv() * 2.0F - 1.0F) * 0.4D;
this.motionY += ((double)(rng.floatv() * 2.0F - 1.0F) + 0.2) * 0.4D;
this.motionZ += (double)(rng.floatv() * 2.0F - 1.0F) * 0.4D;
this.blue = (float)(Math.random() * 0.30000001192092896D + 0.6000000238418579D);
this.red = this.blue * 0.3f;
this.green = this.blue * 0.8f;
@ -235,16 +232,10 @@ public class EffectRenderer {
this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
}
protected Downfall(double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) {
protected Downfall(double xCoordIn, double yCoordIn, double zCoordIn) {
this(xCoordIn, yCoordIn, zCoordIn, 0);
this.gravity = 0.04F;
this.setUV(1 + rng.zrange(3), 1);
if(ySpeedIn == 0.0D && (xSpeedIn != 0.0D || zSpeedIn != 0.0D)) {
this.motionX = xSpeedIn;
this.motionY = ySpeedIn + 0.1D;
this.motionZ = zSpeedIn;
}
}
public boolean onUpdate() {
@ -290,15 +281,15 @@ public class EffectRenderer {
private class Dust extends Particle {
private final float baseScale;
protected Dust(double xCoordIn, double yCoordIn, double zCoordIn, float red, float green, float blue) {
protected Dust(double xCoordIn, double yCoordIn, double zCoordIn, int color) {
super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
this.motionX *= 0.10000000149011612D;
this.motionY *= 0.10000000149011612D;
this.motionZ *= 0.10000000149011612D;
float f = (float)Math.random() * 0.4F + 0.6F;
this.red = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * red * f;
this.green = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * green * f;
this.blue = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * blue * f;
this.red = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * ((float)((color >> 16) & 0xff) / 255.0f) * f;
this.green = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * ((float)((color >> 8) & 0xff) / 255.0f) * f;
this.blue = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * ((float)(color & 0xff) / 255.0f) * f;
this.scale *= 0.75F;
this.baseScale = this.scale;
this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
@ -335,11 +326,11 @@ public class EffectRenderer {
}
private class Explosion extends Particle {
protected Explosion(double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) {
super(xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
this.motionX = xSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.05000000074505806D;
this.motionY = ySpeedIn + (Math.random() * 2.0D - 1.0D) * 0.05000000074505806D;
this.motionZ = zSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.05000000074505806D;
protected Explosion(double xCoordIn, double yCoordIn, double zCoordIn) {
super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
this.motionX = (Math.random() * 2.0D - 1.0D) * 0.05000000074505806D;
this.motionY = (Math.random() * 2.0D - 1.0D) * 0.05000000074505806D;
this.motionZ = (Math.random() * 2.0D - 1.0D) * 0.05000000074505806D;
this.red = this.green = this.blue = rng.floatv() * 0.3F + 0.7F;
this.scale = rng.floatv() * rng.floatv() * 6.0F + 1.0F;
this.lifetime = (int)(16.0D / ((double)rng.floatv() * 0.8D + 0.2D)) + 2;
@ -367,11 +358,11 @@ public class EffectRenderer {
private class Flame extends Particle {
private final float baseScale;
protected Flame(double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) {
super(xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
this.motionX = this.motionX * 0.009999999776482582D + xSpeedIn;
this.motionY = this.motionY * 0.009999999776482582D + ySpeedIn;
this.motionZ = this.motionZ * 0.009999999776482582D + zSpeedIn;
protected Flame(double xCoordIn, double yCoordIn, double zCoordIn) {
super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
this.motionX = this.motionX * 0.009999999776482582D;
this.motionY = this.motionY * 0.009999999776482582D;
this.motionZ = this.motionZ * 0.009999999776482582D;
this.posX += (double)((rng.floatv() - rng.floatv()) * 0.05F);
this.posY += (double)((rng.floatv() - rng.floatv()) * 0.05F);
this.posZ += (double)((rng.floatv() - rng.floatv()) * 0.05F);
@ -504,7 +495,7 @@ public class EffectRenderer {
float f = (float)this.age / (float)this.lifetime;
if(rng.floatv() > f) {
world.spawnParticle(ParticleType.SMOKE, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ);
world.spawnParticle(ParticleType.SMOKE, this.posX, this.posY, this.posZ);
}
this.motionY -= 0.03D;
@ -522,11 +513,11 @@ public class EffectRenderer {
private final double baseY;
private final double baseZ;
protected Teleport(double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) {
super(xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
this.motionX = xSpeedIn;
this.motionY = ySpeedIn;
this.motionZ = zSpeedIn;
protected Teleport(double xCoordIn, double yCoordIn, double zCoordIn) {
super(xCoordIn, yCoordIn, zCoordIn, 0.0, 0.0, 0.0);
this.motionX = (rng.floatv() - 0.5F) * 0.2F;
this.motionY = (rng.floatv() - 0.5F) * 0.2F;
this.motionZ = (rng.floatv() - 0.5F) * 0.2F;
this.baseX = this.posX = xCoordIn;
this.baseY = this.posY = yCoordIn;
this.baseZ = this.posZ = zCoordIn;
@ -585,14 +576,11 @@ public class EffectRenderer {
private class Smoke extends Particle {
private final float baseScale;
protected Smoke(double xCoordIn, double yCoordIn, double zCoordIn, double p_i46348_8_, double p_i46348_10_, double p_i46348_12_) {
protected Smoke(double xCoordIn, double yCoordIn, double zCoordIn) {
super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
this.motionX *= 0.10000000149011612D;
this.motionY *= 0.10000000149011612D;
this.motionZ *= 0.10000000149011612D;
this.motionX += p_i46348_8_;
this.motionY += p_i46348_10_;
this.motionZ += p_i46348_12_;
this.red = this.green = this.blue = (float)(Math.random() * 0.30000001192092896D);
this.scale *= 0.75F;
this.baseScale = this.scale;
@ -633,11 +621,11 @@ public class EffectRenderer {
private class Spell extends Particle {
private final boolean effect;
protected Spell(double xCoordIn, double yCoordIn, double zCoordIn, double p_i1229_8_, double p_i1229_10_, double p_i1229_12_, ItemPotion potion) {
this(xCoordIn, yCoordIn, zCoordIn, p_i1229_8_, p_i1229_10_, p_i1229_12_, potion, rng.doublev() * 4.0D, rng.doublev() * Math.PI * 2.0D);
protected Spell(double xCoordIn, double yCoordIn, double zCoordIn, ItemPotion potion) {
this(xCoordIn, yCoordIn, zCoordIn, potion, rng.doublev() * 4.0D, rng.doublev() * Math.PI * 2.0D);
}
private Spell(double xCoordIn, double yCoordIn, double zCoordIn, double p_i1229_8_, double p_i1229_10_, double p_i1229_12_, ItemPotion potion,
private Spell(double xCoordIn, double yCoordIn, double zCoordIn, ItemPotion potion,
double d22, double d23) {
super(xCoordIn + Math.cos(d23) * d22 * 0.1, yCoordIn + 0.3, zCoordIn + Math.sin(d23) * d22 * 0.1, 0.5 - rng.doublev(),
0.01 + rng.doublev() * 0.5, 0.5 - rng.doublev());
@ -712,16 +700,16 @@ public class EffectRenderer {
protected float green;
protected float blue;
private Icon(double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, float size, TextureAtlasSprite icon) {
super(x, y, z, xSpeed, ySpeed, zSpeed);
private Icon(double x, double y, double z, float size, TextureAtlasSprite icon) {
super(x, y, z, 0.0, 0.0, 0.0);
this.size = (rng.floatv() * 0.5F + 0.5F) * size * 0.1f;
this.icon = icon;
this.offsetX = rng.floatv() * 3.0F;
this.offsetY = rng.floatv() * 3.0F;
}
protected Icon(double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, State state, BlockPos pos, boolean hit) {
this(x, y, z, xSpeed, ySpeed, zSpeed, hit ? 0.6f : 1.0f, Client.CLIENT.getBlockRendererDispatcher().getModelManager().getTexture(state));
protected Icon(double x, double y, double z, State state, BlockPos pos, boolean hit) {
this(x, y, z, hit ? 0.6f : 1.0f, Client.CLIENT.getBlockRendererDispatcher().getModelManager().getTexture(state));
this.gravity = 1.0F;
this.red = this.green = this.blue = 0.6F;
if(hit) {
@ -738,16 +726,13 @@ public class EffectRenderer {
this.blue *= (float)(color & 255) / 255.0F;
}
protected Icon(double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, Item item) {
this(x, y, z, 0.0D, 0.0D, 0.0D, 1.0f, Client.CLIENT.getRenderItem().getItemModelMesher().getParticleIcon(item));
protected Icon(double x, double y, double z, Item item) {
this(x, y, z, 1.0f, Client.CLIENT.getRenderItem().getItemModelMesher().getParticleIcon(item));
this.red = this.green = this.blue = 1.0F;
this.gravity = 1.0F;
this.motionX *= 0.10000000149011612D;
this.motionY *= 0.10000000149011612D;
this.motionZ *= 0.10000000149011612D;
this.motionX += xSpeed;
this.motionY += ySpeed;
this.motionZ += zSpeed;
}
public final int getLayer() {
@ -791,12 +776,14 @@ public class EffectRenderer {
}
}
private class Textured extends Effect {
private class Textured implements Effect {
private static final VertexFormat VERTEX_FORMAT = (new VertexFormat()).addElement(DefaultVertexFormats.POSITION_3F)
.addElement(DefaultVertexFormats.TEX_2F).addElement(DefaultVertexFormats.COLOR_4UB).addElement(DefaultVertexFormats.TEX_2S)
.addElement(DefaultVertexFormats.NORMAL_3B).addElement(DefaultVertexFormats.PADDING_1B);
private final String texture;
private final int texWidth;
private final int texHeight;
private final float scale;
private final float brightness;
private final double posX;
@ -807,45 +794,46 @@ public class EffectRenderer {
private int lifetime;
private TextureManager manager;
protected Textured(TextureManager manager, double x, double y, double z, double scale, String texture) {
protected Textured(TextureManager manager, double x, double y, double z, float scale, String texture, int width, int height) {
this.manager = manager;
this.lifetime = 6 + rng.zrange(4);
this.brightness = rng.floatv() * 0.6F + 0.4F;
this.scale = (float)scale;
this.texture = texture;
this.scale = scale;
this.texture = "textures/world/" + texture + ".png";
this.texWidth = width;
this.texHeight = height;
this.posX = x;
this.posY = y;
this.posZ = z;
}
public final void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ) {
int i = (int)(((float)this.age + partial) * 15.0F / (float)this.lifetime);
if(i <= 15) {
int idx = (int)(((float)this.age + partial) * (float)(this.texWidth * this.texHeight - 1) / (float)this.lifetime);
if(idx < this.texWidth * this.texHeight) {
this.manager.bindTexture(this.texture);
float f = (float)(i % 4) / 4.0F;
float f1 = f + 0.24975F;
float f2 = (float)(i / 4) / 4.0F;
float f3 = f2 + 0.24975F;
float f4 = 2.0F * (1.0F - this.scale * 0.5F);
float f5 = (float)(this.posX - interpPosX);
float f6 = (float)(this.posY - interpPosY);
float f7 = (float)(this.posZ - interpPosZ);
float u1 = (float)(idx % this.texWidth) / (float)this.texWidth;
float u2 = u1 + 1.0f / (float)this.texWidth;
float v1 = (float)(idx / this.texWidth) / (float)this.texHeight;
float v2 = v1 + 1.0f / (float)this.texHeight;
float scale = 2.0F * (1.0F - this.scale * 0.5F);
float x = (float)(this.posX - interpPosX);
float y = (float)(this.posY - interpPosY);
float z = (float)(this.posZ - interpPosZ);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GlState.disableLighting();
ItemRenderer.disableStandardItemLighting();
rb.begin(GL11.GL_QUADS, VERTEX_FORMAT);
rb.pos((double)(f5 - rotX * f4 - rotXY * f4), (double)(f6 - rotZ * f4), (double)(f7 - rotYZ * f4 - rotXZ * f4))
.tex((double)f1, (double)f3).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
rb.pos((double)(x - rotX * scale - rotXY * scale), (double)(y - rotZ * scale), (double)(z - rotYZ * scale - rotXZ * scale))
.tex((double)u2, (double)v2).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
.normal(0.0F, 1.0F, 0.0F).endVertex();
rb.pos((double)(f5 - rotX * f4 + rotXY * f4), (double)(f6 + rotZ * f4), (double)(f7 - rotYZ * f4 + rotXZ * f4))
.tex((double)f1, (double)f2).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
rb.pos((double)(x - rotX * scale + rotXY * scale), (double)(y + rotZ * scale), (double)(z - rotYZ * scale + rotXZ * scale))
.tex((double)u2, (double)v1).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
.normal(0.0F, 1.0F, 0.0F).endVertex();
rb.pos((double)(f5 + rotX * f4 + rotXY * f4), (double)(f6 + rotZ * f4), (double)(f7 + rotYZ * f4 + rotXZ * f4))
.tex((double)f, (double)f2).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
rb.pos((double)(x + rotX * scale + rotXY * scale), (double)(y + rotZ * scale), (double)(z + rotYZ * scale + rotXZ * scale))
.tex((double)u1, (double)v1).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
.normal(0.0F, 1.0F, 0.0F).endVertex();
rb.pos((double)(f5 + rotX * f4 - rotXY * f4), (double)(f6 - rotZ * f4), (double)(f7 + rotYZ * f4 - rotXZ * f4))
.tex((double)f, (double)f3).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
rb.pos((double)(x + rotX * scale - rotXY * scale), (double)(y - rotZ * scale), (double)(z + rotYZ * scale - rotXZ * scale))
.tex((double)u1, (double)v2).color(this.brightness, this.brightness, this.brightness, 1.0F).lightmap(0, 240)
.normal(0.0F, 1.0F, 0.0F).endVertex();
Tessellator.draw();
GlState.enableLighting();
@ -863,8 +851,11 @@ public class EffectRenderer {
}
}
private abstract class Spawner extends Effect {
private final int amount;
private abstract class Spawner implements Effect {
protected final int amount;
protected final int lifetime;
protected int age;
protected Spawner(int amount, int lifetime) {
this.amount = amount;
@ -906,7 +897,7 @@ public class EffectRenderer {
if(x * x + y * y + z * z <= 1.0D)
world.spawnParticle(ParticleType.CRIT, this.entity.posX + x * (double)this.entity.width / 4.0D,
this.entity.getEntityBoundingBox().minY + (double)(this.entity.height / 2.0F) + y * (double)this.entity.height / 4.0D,
this.entity.posZ + z * (double)this.entity.width / 4.0D, x, y + 0.2D, z);
this.entity.posZ + z * (double)this.entity.width / 4.0D);
}
}
@ -926,12 +917,12 @@ public class EffectRenderer {
double x = this.posX + (rng.doublev() - rng.doublev()) * 4.0D;
double y = this.posY + (rng.doublev() - rng.doublev()) * 4.0D;
double z = this.posZ + (rng.doublev() - rng.doublev()) * 4.0D;
world.spawnParticle(ParticleType.EXPLOSION_LARGE, x, y, z, (double)((float)this.age / (float)this.lifetime), 0.0D, 0.0D);
world.spawnParticle(ParticleType.EXPLOSION_LARGE, x, y, z, (int)(100.0f * (float)this.age / (float)this.lifetime));
}
}
private interface Creator {
Effect create(double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data);
Effect create(double x, double y, double z, int data);
}
private static final String TEXTURE = "textures/world/particles.png";
@ -960,33 +951,32 @@ public class EffectRenderer {
}
private void registerEffects() {
this.register(ParticleType.EXPLOSION_NORMAL, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Explosion(x, y, z, xSpeed, ySpeed, zSpeed));
this.register(ParticleType.SPLASH, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Downfall(x, y, z, xSpeed, ySpeed, zSpeed));
this.register(ParticleType.WATER_DROP, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Downfall(x, y, z, 0));
this.register(ParticleType.DEPTH, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Aura(x, y, z, xSpeed, ySpeed, zSpeed, true, 0));
this.register(ParticleType.CRIT, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Crit(x, y, z, xSpeed, ySpeed, zSpeed));
this.register(ParticleType.SMOKE, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Smoke(x, y, z, xSpeed, ySpeed, zSpeed));
this.register(ParticleType.POTION, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Spell(x, y, z, xSpeed, ySpeed, zSpeed,
ItemPotion.getPotionItem(data)));
this.register(ParticleType.GROW, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Aura(x, y, z, xSpeed, ySpeed, zSpeed, false, 1));
this.register(ParticleType.SPORE, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Aura(x, y, z, xSpeed, ySpeed, zSpeed, false, 0));
this.register(ParticleType.TELEPORT, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Teleport(x, y, z, xSpeed, ySpeed, zSpeed));
this.register(ParticleType.FLAME, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Flame(x, y, z, xSpeed, ySpeed, zSpeed));
this.register(ParticleType.LAVA, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new LavaPop(x, y, z));
this.register(ParticleType.DUST, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Dust(x, y, z, (float)xSpeed, (float)ySpeed, (float)zSpeed));
this.register(ParticleType.HEART, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Heart(x, y, z));
this.register(ParticleType.ITEM_CRACK, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> {
Item item = ItemRegistry.byId(data);
return item == null ? null : new Icon(x, y, z, xSpeed, ySpeed, zSpeed, item);
this.register(ParticleType.EXPLOSION_NORMAL, (x, y, z, u) -> new Explosion(x, y, z));
this.register(ParticleType.SPLASH, (x, y, z, u) -> new Downfall(x, y, z));
this.register(ParticleType.WATER_DROP, (x, y, z, u) -> new Downfall(x, y, z, 0));
this.register(ParticleType.DEPTH, (x, y, z, u) -> new Aura(x, y, z, true, 0));
this.register(ParticleType.CRIT, (x, y, z, u) -> new Crit(x, y, z));
this.register(ParticleType.SMOKE, (x, y, z, u) -> new Smoke(x, y, z));
this.register(ParticleType.POTION, (x, y, z, id) -> new Spell(x, y, z, ItemPotion.getPotionItem(id)));
this.register(ParticleType.GROW, (x, y, z, u) -> new Aura(x, y, z, false, 1));
this.register(ParticleType.SPORE, (x, y, z, u) -> new Aura(x, y, z, false, 0));
this.register(ParticleType.TELEPORT, (x, y, z, u) -> new Teleport(x, y, z));
this.register(ParticleType.FLAME, (x, y, z, u) -> new Flame(x, y, z));
this.register(ParticleType.LAVA, (x, y, z, u) -> new LavaPop(x, y, z));
this.register(ParticleType.DUST, (x, y, z, color) -> new Dust(x, y, z, color));
this.register(ParticleType.HEART, (x, y, z, u) -> new Heart(x, y, z));
this.register(ParticleType.ITEM_CRACK, (x, y, z, id) -> {
Item item = ItemRegistry.byId(id);
return item == null ? null : new Icon(x, y, z, item);
});
this.register(ParticleType.BLOCK_CRACK, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> {
State state = BlockRegistry.byId(data);
return state == null ? null : new Icon(x, y, z, xSpeed, ySpeed, zSpeed, state, null, false);
this.register(ParticleType.BLOCK_CRACK, (x, y, z, id) -> {
State state = BlockRegistry.byId(id);
return state == null ? null : new Icon(x, y, z, state, null, false);
});
this.register(ParticleType.EXPLOSION_HUGE, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new ExplosionSpawner(x, y, z));
this.register(ParticleType.EXPLOSION_HUGE, (x, y, z, u) -> new ExplosionSpawner(x, y, z));
this.register(ParticleType.EXPLOSION_LARGE,
(x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Textured(this.manager, x, y, z, xSpeed, "textures/entity/explosion.png"));
this.register(ParticleType.HAIL_CORN, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Downfall(x, y, z, 1));
(x, y, z, scale) -> new Textured(this.manager, x, y, z, (float)scale / 100.0f, "explosion", 4, 4));
this.register(ParticleType.HAIL_CORN, (x, y, z, u) -> new Downfall(x, y, z, 1));
}
public void setWorld(World world) {
@ -1079,10 +1069,10 @@ public class EffectRenderer {
this.layers[i].add(effect);
}
public void spawnParticle(ParticleType type, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data) {
public void spawnParticle(ParticleType type, double x, double y, double z, int data) {
Creator creator = this.types.get(type);
if(creator != null) {
Effect effect = creator.create(x, y, z, xSpeed, ySpeed, zSpeed, data);
Effect effect = creator.create(x, y, z, data);
if(effect != null)
this.add(effect);
}
@ -1099,8 +1089,7 @@ public class EffectRenderer {
double d0 = (double)pos.getX() + ((double)j + 0.5D) / (double)i;
double d1 = (double)pos.getY() + ((double)k + 0.5D) / (double)i;
double d2 = (double)pos.getZ() + ((double)l + 0.5D) / (double)i;
this.add(new Icon(d0, d1, d2, d0 - (double)pos.getX() - 0.5D, d1 - (double)pos.getY() - 0.5D, d2 - (double)pos.getZ() - 0.5D,
state, pos, false));
this.add(new Icon(d0, d1, d2, state, pos, false));
}
}
}
@ -1147,7 +1136,7 @@ public class EffectRenderer {
d0 = (double)i + block.getBlockBoundsMaxX() + (double)f;
}
this.add(new Icon(d0, d1, d2, 0.0D, 0.0D, 0.0D, iblockstate, pos, true));
this.add(new Icon(d0, d1, d2, iblockstate, pos, true));
}
}

View file

@ -1133,7 +1133,7 @@ public class EntityRenderer {
}
}
if(temp < 194.0f || this.random.chance(8))
this.gm.world.spawnParticle(temp >= 194.0f && this.random.chance(20) ? ParticleType.LAVA : ParticleType.SMOKE, (double)blockpos1.getX() + d3, (double)((float)blockpos1.getY() + 0.1F) - block.getBlockBoundsMinY(), (double)blockpos1.getZ() + d4, 0.0D, 0.0D, 0.0D);
this.gm.world.spawnParticle(temp >= 194.0f && this.random.chance(20) ? ParticleType.LAVA : ParticleType.SMOKE, (double)blockpos1.getX() + d3, (double)((float)blockpos1.getY() + 0.1F) - block.getBlockBoundsMinY(), (double)blockpos1.getZ() + d4);
}
else if (block != Blocks.air)
{
@ -1147,7 +1147,7 @@ public class EntityRenderer {
d2 = (double)blockpos2.getZ() + d4;
}
this.gm.world.spawnParticle(temp <= 5.0f ? ParticleType.HAIL_CORN : ParticleType.WATER_DROP, (double)blockpos2.getX() + d3, (double)((float)blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY(), (double)blockpos2.getZ() + d4, 0.0D, 0.0D, 0.0D);
this.gm.world.spawnParticle(temp <= 5.0f ? ParticleType.HAIL_CORN : ParticleType.WATER_DROP, (double)blockpos2.getX() + d3, (double)((float)blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY(), (double)blockpos2.getZ() + d4);
}
}
}

View file

@ -297,7 +297,7 @@ public class WorldClient extends AWorldClient
float x = ((float)posX) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
float y = -64.0f + rand.floatv() * 65.0f; // * 68.0f;
float z = ((float)posZ) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
this.spawnParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z, 0.0D, 0.0D, 0.0D);
this.spawnParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z);
}
// }
}
@ -414,15 +414,14 @@ public class WorldClient extends AWorldClient
// zOffset, data);
// }
public void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset,
double zOffset, int data) {
public void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, int data) {
if (this.gm.getRenderViewEntity() != null)
{
double d0 = this.gm.getRenderViewEntity().posX - xCoord;
double d1 = this.gm.getRenderViewEntity().posY - yCoord;
double d2 = this.gm.getRenderViewEntity().posZ - zCoord;
if(particle.isUnlimited() || d0 * d0 + d1 * d1 + d2 * d2 <= 256.0D)
this.gm.effectRenderer.spawnParticle(particle, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, data);
this.gm.effectRenderer.spawnParticle(particle, xCoord, yCoord, zCoord, data);
}
}
@ -574,6 +573,14 @@ public class WorldClient extends AWorldClient
case 1025:
MutableBlockPos pos = new MutableBlockPos(blockPosIn.getX(), blockPosIn.getY(), blockPosIn.getZ());
for(int z = 0; z < 1000; z++) {
this.spawnParticle(ParticleType.EXPLOSION_HUGE,
(double)pos.getX() + this.rand.gaussian() * 128.0, (double)pos.getY() + this.rand.gaussian() * 2.0, (double)pos.getZ() + this.rand.gaussian() * 128.0);
}
for(int z = 0; z < 1000; z++) {
this.spawnParticle(ParticleType.EXPLOSION_NORMAL,
(double)pos.getX() + this.rand.gaussian() * 128.0, (double)pos.getY() + this.rand.gaussian() * 2.0, (double)pos.getZ() + this.rand.gaussian() * 128.0, 100);
}
for(int z = 0; z < 30; z++) {
this.playSoundAtPos(pos.set(blockPosIn.getX() + this.rand.range(-128, 128),
blockPosIn.getY() + this.rand.range(-4, 4), blockPosIn.getZ() + this.rand.range(-128, 128)),
@ -594,10 +601,7 @@ public class WorldClient extends AWorldClient
double d21 = d15 + (double)l * 0.01D + (this.rand.doublev() - 0.5D) * (double)i * 0.5D;
double d4 = d17 + (this.rand.doublev() - 0.5D) * 0.5D;
double d6 = d19 + (double)i * 0.01D + (this.rand.doublev() - 0.5D) * (double)l * 0.5D;
double d8 = (double)l * d20 + this.rand.gaussian() * 0.01D;
double d10 = -0.03D + this.rand.gaussian() * 0.01D;
double d12 = (double)i * d20 + this.rand.gaussian() * 0.01D;
this.spawnParticle(ParticleType.SMOKE, d21, d4, d6, d8, d10, d12);
this.spawnParticle(ParticleType.SMOKE, d21, d4, d6);
}
return;
@ -620,12 +624,12 @@ public class WorldClient extends AWorldClient
for (int i1 = 0; i1 < 8; ++i1)
{
this.spawnParticle(ParticleType.ITEM_CRACK, d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, ItemRegistry.getId(Items.water_bottle));
this.spawnParticle(ParticleType.ITEM_CRACK, d13, d14, d16, ItemRegistry.getId(Items.water_bottle));
}
for (int l1 = 0; l1 < 100; ++l1)
{
this.spawnParticle(ParticleType.POTION, d13, d14, d16, 0.0, 0.0, 0.0, data);
this.spawnParticle(ParticleType.POTION, d13, d14, d16, data);
}
this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F);

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Before After
Before After