diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index f8af0e09..68a57713 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -59,6 +59,7 @@ import client.network.ClientPlayer; import client.network.DummyConnection; import client.renderer.BlockRenderer; import client.renderer.Drawing; +import client.renderer.EffectRenderer; import client.renderer.EntityRenderer; import client.renderer.GlState; import client.renderer.ItemRenderer; @@ -68,7 +69,6 @@ import client.renderer.blockmodel.ModelManager; import client.renderer.chunk.RenderChunk; import client.renderer.entity.RenderItem; import client.renderer.entity.RenderManager; -import client.renderer.particle.EffectRenderer; import client.renderer.texture.ColormapLoader; import client.renderer.texture.EntityTexManager; import client.renderer.texture.TextureManager; @@ -696,7 +696,7 @@ public class Client implements IThreadListener { this.renderGlobal = new RenderGlobal(this); this.renderGlobal.onReload(); EntityTexManager.loadNpcTextures(); - this.effectRenderer = new EffectRenderer(this.world, this.textureManager); + this.effectRenderer = new EffectRenderer(this.textureManager); } public void start() @@ -898,7 +898,7 @@ public class Client implements IThreadListener { { this.world.displayTick(ExtMath.floord(this.player.posX), ExtMath.floord(this.player.posY), ExtMath.floord(this.player.posZ)); } - this.effectRenderer.updateEffects(); + this.effectRenderer.update(); } else if (this.connection != null) { @@ -1378,7 +1378,7 @@ public class Client implements IThreadListener { if (this.world.getState(blockpos).getBlock() != Blocks.air && this.controller.damageBlock(blockpos, this.pointed.side)) { - this.effectRenderer.addBlockHitEffects(blockpos, this.pointed.side); + this.effectRenderer.damageBlock(blockpos, this.pointed.side); this.player.swingItem(); } } @@ -1604,7 +1604,7 @@ public class Client implements IThreadListener { if (this.effectRenderer != null) { - this.effectRenderer.clearEffects(world); + this.effectRenderer.setWorld(world); } if (this.player == null) @@ -1898,7 +1898,7 @@ public class Client implements IThreadListener { // this.connected != null ? this.connected : "[???]"))), this.renderGlobal.getDebugInfoRenders() + "\n" + this.renderGlobal.getDebugInfoEntities() + "\n" + - "Partikel: " + this.effectRenderer.getStatistics() + ". O: " + this.world.getDebugLoadedEntities() + "\n" + + "Partikel: " + this.effectRenderer.getParticleCount() + ". O: " + this.world.getDebugLoadedEntities() + "\n" + this.world.getInfo() + "\n" + // "", String.format("XYZ: %.3f / %.3f / %.3f", this.viewEntity.posX, diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index f22f5faa..c17a5149 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -47,7 +47,6 @@ import common.inventory.InventoryBasic; import common.inventory.InventoryPlayer; import common.item.ItemStack; import common.log.Log; -import common.model.ParticleType; import common.network.IClientPlayer; import common.network.NetConnection; import common.network.NetHandler; @@ -1855,8 +1854,7 @@ public class ClientPlayer implements IClientPlayer try { - ParticleType particle = packetIn.getParticleType(); - this.world.spawnEntityFX(particle, particle.isUnlimited() | packetIn.isLongDistance(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), d0, d2, d4, packetIn.getParticleArg()); + this.world.spawnParticle(packetIn.getParticleType(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), d0, d2, d4, packetIn.getParticleArg()); } catch (Throwable var17) { @@ -1876,8 +1874,7 @@ public class ClientPlayer implements IClientPlayer try { - ParticleType particle = packetIn.getParticleType(); - this.world.spawnEntityFX(particle, particle.isUnlimited() | packetIn.isLongDistance(), packetIn.getXCoordinate() + d1, packetIn.getYCoordinate() + d3, packetIn.getZCoordinate() + d5, d6, d7, d8, packetIn.getParticleArg()); + this.world.spawnParticle(packetIn.getParticleType(), packetIn.getXCoordinate() + d1, packetIn.getYCoordinate() + d3, packetIn.getZCoordinate() + d5, d6, d7, d8, packetIn.getParticleArg()); } catch (Throwable var16) { diff --git a/client/src/main/java/client/renderer/EffectRenderer.java b/client/src/main/java/client/renderer/EffectRenderer.java new file mode 100755 index 00000000..73fd43ec --- /dev/null +++ b/client/src/main/java/client/renderer/EffectRenderer.java @@ -0,0 +1,1157 @@ +package client.renderer; + +import java.util.List; +import java.util.Map; + +import org.lwjgl.opengl.GL11; + +import client.Client; +import client.renderer.texture.TextureAtlasSprite; +import client.renderer.texture.TextureManager; +import client.renderer.texture.TextureMap; +import common.block.Block; +import common.block.Material; +import common.block.liquid.BlockLiquid; +import common.collect.Lists; +import common.collect.Maps; +import common.entity.Entity; +import common.init.BlockRegistry; +import common.init.Blocks; +import common.init.ItemRegistry; +import common.item.Item; +import common.item.tool.ItemPotion; +import common.model.ParticleType; +import common.rng.Random; +import common.util.BlockPos; +import common.util.ExtMath; +import common.util.Facing; +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 abstract class Moveable extends Effect { + protected double prevX; + protected double prevY; + protected double prevZ; + protected double posX; + protected double posY; + protected double posZ; + protected double motionX; + protected double motionY; + protected double motionZ; + + protected float gravity; + + protected Moveable(double posXIn, double posYIn, double posZIn) { + this.posX = this.prevX = posXIn; + this.posY = this.prevY = posYIn; + this.posZ = this.prevZ = posZIn; + this.lifetime = (int)(4.0F / (rng.floatv() * 0.9F + 0.1F)); + this.age = 0; + } + + public Moveable(double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) { + this(xCoordIn, yCoordIn, zCoordIn); + this.motionX = xSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D; + this.motionY = ySpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D; + this.motionZ = zSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D; + float f = (float)(Math.random() + Math.random() + 1.0D) * 0.15F; + float f1 = ExtMath.sqrtd(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.motionX = this.motionX / (double)f1 * (double)f * 0.4000000059604645D; + this.motionY = this.motionY / (double)f1 * (double)f * 0.4000000059604645D + 0.10000000149011612D; + this.motionZ = this.motionZ / (double)f1 * (double)f * 0.4000000059604645D; + } + + public final void move(double x, double y, double z) { + this.posX += x; + this.posY += y; + this.posZ += z; + } + + public int getBrightness(float partial) { + BlockPos pos = new BlockPos(this.posX, this.posY, this.posZ); + return world.isBlockLoaded(pos) ? world.getCombinedLight(pos, 0) : 0; + } + } + + private abstract class Particle extends Moveable { + private int textureU; + private int textureV; + protected float scale; + protected float red; + protected float green; + protected float blue; + + public Particle(double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { + super(x, y, z, xSpeed, ySpeed, zSpeed); + this.red = this.green = this.blue = 1.0F; + this.scale = (rng.floatv() * 0.5F + 0.5F) * 2.0F; + } + + protected void setScale(float partial) { + } + + 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(); + } + + public final int getLayer() { + return 0; + } + + protected final void setUV(int x, int y) { + this.textureU = x; + this.textureV = y; + } + } + + 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, + int texture) { + super(xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, speedIn); + float f = texture != 0 ? 1.0f : rng.floatv() * 0.1F + 0.2F; + this.red = f; + this.green = f; + this.blue = f; + this.setUV(texture != 0 ? 5 + texture : 0, texture != 0 ? 2 : 0); + this.scale *= rng.floatv() * 0.6F + 0.5F; + this.motionX *= 0.019999999552965164D; + this.motionY *= 0.019999999552965164D; + this.motionZ *= 0.019999999552965164D; + this.lifetime = (int)(20.0D / (Math.random() * 0.8D + 0.2D)); + this.fullBright = fullBright; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.99D; + this.motionY *= 0.99D; + this.motionZ *= 0.99D; + + if(this.lifetime-- <= 0) { + return true; + } + return false; + } + + public int getBrightness(float partialTicks) { + return this.fullBright ? 15728880 : super.getBrightness(partialTicks); + } + } + + 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_) { + 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.blue = (float)(Math.random() * 0.30000001192092896D + 0.6000000238418579D); + this.red = this.blue * 0.3f; + this.green = this.blue * 0.8f; + this.scale *= 0.75F; + this.baseScale = this.scale; + this.lifetime = (int)(6.0D / (Math.random() * 0.8D + 0.6D)); + this.setUV(4, 2); + this.onUpdate(); + } + + protected void setScale(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; + f = ExtMath.clampf(f, 0.0F, 1.0F); + this.scale = this.baseScale * f; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + this.move(this.motionX, this.motionY, this.motionZ); + this.green = (float)((double)this.green * 0.96D); + this.blue = (float)((double)this.blue * 0.9D); + this.motionX *= 0.699999988079071D; + this.motionY *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY -= 0.019999999552965164D; + return false; + } + } + + private class Downfall extends Particle { + protected Downfall(double xCoordIn, double yCoordIn, double zCoordIn, int texture) { + super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.30000001192092896D; + this.motionY = Math.random() * 0.20000000298023224D + 0.10000000149011612D; + this.motionZ *= 0.30000001192092896D; + this.red = 1.0F; + this.green = 1.0F; + this.blue = 1.0F; + this.setUV(rng.zrange(4), 1 + texture); + this.gravity = 0.06F; + 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) { + 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() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + this.motionY -= (double)this.gravity; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if(this.lifetime-- <= 0) { + return true; + } + + BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ); + State iblockstate = world.getState(blockpos); + Block block = iblockstate.getBlock(); + block.setBlockBoundsBasedOnState(world, blockpos); + Material material = iblockstate.getBlock().getMaterial(); + + if(material.isLiquid() || material.isSolid()) { + double d0 = 0.0D; + + if(iblockstate.getBlock() instanceof BlockLiquid) { + d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue())); + } + else { + d0 = block.getBlockBoundsMaxY(); + } + + double d1 = (double)ExtMath.floord(this.posY) + d0; + + if(this.posY < d1) { + return true; + } + } + return false; + } + } + + private class Dust extends Particle { + private final float baseScale; + + protected Dust(double xCoordIn, double yCoordIn, double zCoordIn, float red, float green, float blue) { + 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.scale *= 0.75F; + this.baseScale = this.scale; + this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + } + + protected void setScale(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; + f = ExtMath.clampf(f, 0.0F, 1.0F); + this.scale = this.baseScale * f; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 0); + this.move(this.motionX, this.motionY, this.motionZ); + + if(this.posY == this.prevY) { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + return false; + } + } + + 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; + 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; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 0); + this.motionY += 0.004D; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.8999999761581421D; + this.motionY *= 0.8999999761581421D; + this.motionZ *= 0.8999999761581421D; + return false; + } + } + + 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; + 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); + this.baseScale = this.scale; + this.red = this.green = this.blue = 1.0F; + this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)) + 4; + this.setUV(6, 1); + } + + protected void setScale(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime; + this.scale = this.baseScale * (1.0F - f * f * 0.5F); + } + + public int getBrightness(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime; + f = ExtMath.clampf(f, 0.0F, 1.0F); + int i = super.getBrightness(partialTicks); + int j = i & 255; + int k = i >> 16 & 255; + j = j + (int)(f * 15.0F * 16.0F); + + if(j > 240) { + j = 240; + } + + return j | k << 16; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + return false; + } + } + + private class Heart extends Particle { + private final float baseScale; + + protected Heart(double xCoordIn, double yCoordIn, double zCoordIn) { + super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.009999999776482582D; + this.motionY *= 0.009999999776482582D; + this.motionZ *= 0.009999999776482582D; + this.motionY += 0.1D; + this.scale *= 0.75F; + this.baseScale = this.scale; + this.lifetime = 16; + this.setUV(5, 2); + } + + protected void setScale(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; + f = ExtMath.clampf(f, 0.0F, 1.0F); + this.scale = this.baseScale * f; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + this.move(this.motionX, this.motionY, this.motionZ); + + if(this.posY == this.prevY) { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.8600000143051147D; + this.motionY *= 0.8600000143051147D; + this.motionZ *= 0.8600000143051147D; + return false; + } + } + + private class LavaPop extends Particle { + private final float baseScale; + + protected LavaPop(double xCoordIn, double yCoordIn, double zCoordIn) { + super(xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + this.motionY = (double)(rng.floatv() * 0.4F + 0.05F); + this.red = this.green = this.blue = 1.0F; + this.scale *= rng.floatv() * 2.0F + 0.2F; + this.baseScale = this.scale; + this.lifetime = (int)(16.0D / (Math.random() * 0.8D + 0.2D)); + this.setUV(7, 1); + } + + public int getBrightness(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime; + f = ExtMath.clampf(f, 0.0F, 1.0F); + int i = super.getBrightness(partialTicks); + int j = 240; + int k = i >> 16 & 255; + return j | k << 16; + } + + protected void setScale(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime; + this.scale = this.baseScale * (1.0F - f * f); + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + 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); + } + + this.motionY -= 0.03D; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9990000128746033D; + this.motionY *= 0.9990000128746033D; + this.motionZ *= 0.9990000128746033D; + return false; + } + } + + private class Teleport extends Particle { + private final float baseScale; + private final double baseX; + 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; + this.baseX = this.posX = xCoordIn; + this.baseY = this.posY = yCoordIn; + this.baseZ = this.posZ = zCoordIn; + float f = rng.floatv() * 0.6F + 0.4F; + this.baseScale = this.scale = rng.floatv() * 0.2F + 0.5F; + this.red = this.green = this.blue = 1.0F * f; + this.green *= 0.1F; + this.red *= 0.2F; + this.blue *= 0.25F; + this.lifetime = (int)(Math.random() * 10.0D) + 40; + this.setUV((int)(Math.random() * 8.0D), 0); + } + + protected void setScale(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime; + f = 1.0F - f; + f = f * f; + f = 1.0F - f; + this.scale = this.baseScale * f; + } + + public int getBrightness(float partialTicks) { + int i = super.getBrightness(partialTicks); + float f = (float)this.age / (float)this.lifetime; + f = f * f; + f = f * f; + int j = i & 255; + int k = i >> 16 & 255; + k = k + (int)(f * 15.0F * 16.0F); + + if(k > 240) { + k = 240; + } + + return j | k << 16; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + float f = (float)this.age / (float)this.lifetime; + f = -f + f * f * 2.0F; + f = 1.0F - f; + this.posX = this.baseX + this.motionX * (double)f; + this.posY = this.baseY + this.motionY * (double)f + (double)(1.0F - f); + this.posZ = this.baseZ + this.motionZ * (double)f; + + if(this.age++ >= this.lifetime) { + return true; + } + return false; + } + } + + 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_) { + 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; + this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + } + + protected void setScale(float partialTicks) { + float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; + f = ExtMath.clampf(f, 0.0F, 1.0F); + this.scale = this.baseScale * f; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 0); + this.motionY += 0.004D; + this.move(this.motionX, this.motionY, this.motionZ); + + if(this.posY == this.prevY) { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + return false; + } + } + + private class Spell extends Particle { + protected Spell(double xCoordIn, double yCoordIn, double zCoordIn, double p_i1229_8_, double p_i1229_10_, double p_i1229_12_, int color) { + this(xCoordIn, yCoordIn, zCoordIn, p_i1229_8_, p_i1229_10_, p_i1229_12_, color, 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_, int j1, + 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()); + this.motionY *= 0.20000000298023224D; + + if(Math.cos(d23) * d22 == 0.0D && Math.sin(d23) * d22 == 0.0D) { + this.motionX *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + } + + this.scale *= 0.75F; + this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + + float f = 1.0F; + float f1 = 1.0F; + float f2 = 1.0F; + if(j1 != 0xffffffff) { + f = (float)(j1 >> 16 & 255) / 255.0F; + f1 = (float)(j1 >> 8 & 255) / 255.0F; + f2 = (float)(j1 >> 0 & 255) / 255.0F; + } + this.motionX *= d22; + this.motionY = (this.motionY - 0.10000000149011612D) * d22 + 0.10000000149011612D; + this.motionZ *= d22; + float f3 = 0.75F + rng.floatv() * 0.25F; + this.red = f * f3; + this.green = f1 * f3; + this.blue = f2 * f3; + } + + public boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + + if(this.age++ >= this.lifetime) { + return true; + } + + this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 3); + this.motionY += 0.004D; + this.move(this.motionX, this.motionY, this.motionZ); + + if(this.posY == this.prevY) { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + return false; + } + } + + private class Icon extends Moveable { + private final TextureAtlasSprite icon; + private final float offsetX; + private final float offsetY; + private final float size; + + protected float red; + 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); + 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)); + this.gravity = 1.0F; + this.red = this.green = this.blue = 0.6F; + if(hit) { + this.motionX *= 0.2; + this.motionY = (this.motionY - 0.1) * 0.2 + 0.1; + this.motionZ *= 0.2; + } + Block block = state.getBlock(); + if(block == Blocks.grass) + return; + int color = pos == null ? block.getRenderColor(state) : block.colorMultiplier(world, pos); + this.red *= (float)(color >> 16 & 255) / 255.0F; + this.green *= (float)(color >> 8 & 255) / 255.0F; + 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)); + 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() { + return 1; + } + + public final void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ) { + float u1 = this.icon.getInterpolatedU((double)(this.offsetX * 4.0F)); + float u2 = this.icon.getInterpolatedU((double)((this.offsetX + 1.0F) * 4.0F)); + float v1 = this.icon.getInterpolatedV((double)(this.offsetY * 4.0F)); + float v2 = this.icon.getInterpolatedV((double)((this.offsetY + 1.0F) * 4.0F)); + float scale = this.size; + 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)u1, (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)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)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)u2, (double)v2).color(this.red, this.green, this.blue, 1.0F).lightmap(sky, block).endVertex(); + } + + public final boolean onUpdate() { + this.prevX = this.posX; + this.prevY = this.posY; + this.prevZ = this.posZ; + if(this.age++ >= this.lifetime) + return true; + this.motionY -= 0.04D * (double)this.gravity; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + return false; + } + } + + private class Textured extends 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 float scale; + private final float brightness; + private final double posX; + private final double posY; + private final double posZ; + + private int age; + private int lifetime; + private TextureManager manager; + + protected Textured(TextureManager manager, double x, double y, double z, double scale, String texture) { + 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.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) { + 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); + 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) + .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) + .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) + .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) + .normal(0.0F, 1.0F, 0.0F).endVertex(); + Tessellator.draw(); + GlState.enableLighting(); + } + } + + public final boolean onUpdate() { + if(++this.age >= this.lifetime) + return true; + return false; + } + + public final int getLayer() { + return 2; + } + } + + private abstract class Spawner extends Effect { + private final int amount; + + protected Spawner(int amount, int lifetime) { + this.amount = amount; + this.lifetime = lifetime; + } + + public final boolean onUpdate() { + for(int z = 0; z < this.amount; z++) { + this.spawnParticle(); + } + if(++this.age >= this.lifetime) + return true; + return false; + } + + public final int getLayer() { + return 3; + } + + public final void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ) { + } + + protected abstract void spawnParticle(); + } + + private class HitSpawner extends Spawner { + private final Entity entity; + + public HitSpawner(Entity entity) { + super(16, 3); + this.entity = entity; + this.onUpdate(); + } + + public void spawnParticle() { + double x = (double)(rng.floatv() * 2.0F - 1.0F); + double y = (double)(rng.floatv() * 2.0F - 1.0F); + double z = (double)(rng.floatv() * 2.0F - 1.0F); + 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); + } + } + + private class ExplosionSpawner extends Spawner { + private final double posX; + private final double posY; + private final double posZ; + + protected ExplosionSpawner(double x, double y, double z) { + super(6, 8); + this.posX = x; + this.posY = y; + this.posZ = z; + } + + public void spawnParticle() { + 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); + } + } + + private interface Creator { + Effect create(double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data); + } + + private static final String TEXTURE = "textures/world/particles.png"; + + private final Random rng = new Random(); + private final List[] layers = new List[4]; + private final TextureManager manager; + private final Random rand = new Random(); + private final Map types = Maps.newEnumMap(ParticleType.class); + + private World world; + private double interpPosX; + private double interpPosY; + private double interpPosZ; + + public EffectRenderer(TextureManager manager) { + this.manager = manager; + for(int i = 0; i < this.layers.length; ++i) { + this.layers[i] = Lists.newArrayList(); + } + this.registerEffects(); + } + + private void register(ParticleType type, Creator factory) { + this.types.put(type, factory); + } + + 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, + (data & 16383) != 0 ? ItemPotion.getPotionItem(data).getColorFromDamage() : 0xffffffff)); + 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.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.EXPLOSION_HUGE, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> 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)); + } + + public void setWorld(World world) { + this.world = world; + for(int i = 0; i < this.layers.length; ++i) { + this.layers[i].clear(); + } + } + + public void update() { + for(int i = 0; i < this.layers.length; ++i) { + List layer = this.layers[i]; + List list = Lists.newArrayList(); + for(int n = 0; n < layer.size(); ++n) { + Effect effect = layer.get(n); + if(effect.onUpdate()) + list.add(effect); + } + layer.removeAll(list); + } + } + + public void render(Entity entity, float partial) { + float f = MatrixState.getRotationX(); + float f1 = MatrixState.getRotationZ(); + float f2 = MatrixState.getRotationYZ(); + float f3 = MatrixState.getRotationXY(); + float f4 = MatrixState.getRotationXZ(); + this.interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partial; + this.interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial; + this.interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partial; + GlState.enableBlend(); + GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlState.alphaFunc(GL11.GL_GREATER, 0.003921569F); + + for(int i = 0; i < 2; ++i) { + if(!this.layers[i].isEmpty()) { + GlState.depthMask(true); + + switch(i) { + case 0: + default: + this.manager.bindTexture(TEXTURE); + break; + + case 1: + this.manager.bindTexture(TextureMap.BLOCKS); + } + + GlState.color(1.0F, 1.0F, 1.0F, 1.0F); + RenderBuffer worldrenderer = Tessellator.getBuffer(); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); + + for(int k = 0; k < this.layers[i].size(); ++k) { + this.layers[i].get(k).render(worldrenderer, partial, f, f4, f1, f2, f3); + } + + Tessellator.draw(); + } + } + + GlState.depthMask(true); + GlState.disableBlend(); + GlState.alphaFunc(GL11.GL_GREATER, 0.1F); + } + + public void renderTextured(Entity entity, float partial) { + float f = 0.017453292F; + float f1 = ExtMath.cos(entity.rotYaw * 0.017453292F); + float f2 = ExtMath.sin(entity.rotYaw * 0.017453292F); + float f3 = -f2 * ExtMath.sin(entity.rotPitch * 0.017453292F); + float f4 = f1 * ExtMath.sin(entity.rotPitch * 0.017453292F); + float f5 = ExtMath.cos(entity.rotPitch * 0.017453292F); + + List list = this.layers[2]; + + if(!list.isEmpty()) { + RenderBuffer worldrenderer = Tessellator.getBuffer(); + + for(int j = 0; j < list.size(); ++j) { + list.get(j).render(worldrenderer, partial, f1, f5, f2, f3, f4); + } + } + } + + private void add(Effect effect) { + int i = effect.getLayer(); + if(this.layers[i].size() >= 4000) + this.layers[i].remove(0); + this.layers[i].add(effect); + } + + public Effect spawnParticle(ParticleType type, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data) { + Creator creator = this.types.get(type); + if(creator != null) { + Effect effect = creator.create(x, y, z, xSpeed, ySpeed, zSpeed, data); + if(effect != null) { + this.add(effect); + return effect; + } + } + return null; + } + + public void destroyBlock(BlockPos pos, State state) { + if(state.getBlock() != Blocks.air) { + state = state.getBlock().getActualState(state, this.world, pos); + int i = 4; + + for(int j = 0; j < i; ++j) { + for(int k = 0; k < i; ++k) { + for(int l = 0; l < i; ++l) { + 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)); + } + } + } + } + } + + public void damageBlock(BlockPos pos, Facing side) { + State iblockstate = this.world.getState(pos); + Block block = iblockstate.getBlock(); + + if(block.getRenderType() != -1) { + int i = pos.getX(); + int j = pos.getY(); + int k = pos.getZ(); + float f = 0.1F; + double d0 = (double)i + this.rng.doublev() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (double)(f * 2.0F)) + (double)f + + block.getBlockBoundsMinX(); + double d1 = (double)j + this.rng.doublev() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (double)(f * 2.0F)) + (double)f + + block.getBlockBoundsMinY(); + double d2 = (double)k + this.rng.doublev() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (double)(f * 2.0F)) + (double)f + + block.getBlockBoundsMinZ(); + + if(side == Facing.DOWN) { + d1 = (double)j + block.getBlockBoundsMinY() - (double)f; + } + + if(side == Facing.UP) { + d1 = (double)j + block.getBlockBoundsMaxY() + (double)f; + } + + if(side == Facing.NORTH) { + d2 = (double)k + block.getBlockBoundsMinZ() - (double)f; + } + + if(side == Facing.SOUTH) { + d2 = (double)k + block.getBlockBoundsMaxZ() + (double)f; + } + + if(side == Facing.WEST) { + d0 = (double)i + block.getBlockBoundsMinX() - (double)f; + } + + if(side == Facing.EAST) { + d0 = (double)i + block.getBlockBoundsMaxX() + (double)f; + } + + this.add(new Icon(d0, d1, d2, 0.0D, 0.0D, 0.0D, iblockstate, pos, true)); + } + } + + public void spawnCritParticles(Entity entity) { + this.add(new HitSpawner(entity)); + } + + public int getParticleCount() { + int i = 0; + for(int j = 0; j < 3; ++j) { + i += this.layers[j].size(); + } + return i; + } +} diff --git a/client/src/main/java/client/renderer/EntityRenderer.java b/client/src/main/java/client/renderer/EntityRenderer.java index 6745979b..e61373d2 100755 --- a/client/src/main/java/client/renderer/EntityRenderer.java +++ b/client/src/main/java/client/renderer/EntityRenderer.java @@ -10,7 +10,6 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; import client.Client; -import client.renderer.particle.EffectRenderer; import client.renderer.texture.DynamicTexture; import client.renderer.texture.TextureMap; import client.world.WorldClient; @@ -1011,10 +1010,10 @@ public class EntityRenderer { // if (!this.debugView) // { this.enableLightmap(); - effectrenderer.renderLitParticles(entity, partialTicks); + effectrenderer.renderTextured(entity, partialTicks); ItemRenderer.disableStandardItemLighting(); this.setupFog(0, partialTicks); - effectrenderer.renderParticles(entity, partialTicks); + effectrenderer.render(entity, partialTicks); this.disableLightmap(); // } diff --git a/client/src/main/java/client/renderer/particle/EffectRenderer.java b/client/src/main/java/client/renderer/particle/EffectRenderer.java deleted file mode 100755 index 879ac730..00000000 --- a/client/src/main/java/client/renderer/particle/EffectRenderer.java +++ /dev/null @@ -1,309 +0,0 @@ -package client.renderer.particle; - -import java.util.List; -import java.util.Map; - -import org.lwjgl.opengl.GL11; - -import client.renderer.MatrixState; -import client.renderer.DefaultVertexFormats; -import client.renderer.GlState; -import client.renderer.RenderBuffer; -import client.renderer.Tessellator; -import client.renderer.texture.TextureManager; -import client.renderer.texture.TextureMap; -import common.block.Block; -import common.collect.Lists; -import common.collect.Maps; -import common.entity.Entity; -import common.init.Blocks; -import common.model.ParticleType; -import common.rng.Random; -import common.util.BlockPos; -import common.util.ExtMath; -import common.util.Facing; -import common.world.State; -import common.world.World; - -public class EffectRenderer -{ - private static final String TEXTURE = "textures/world/particles.png"; - - protected World worldObj; - private List[] fxLayers = new List[4]; - private TextureManager renderer; - private Random rand = new Random(); - private Map particleTypes = Maps.newEnumMap(ParticleType.class); - - public EffectRenderer(World worldIn, TextureManager rendererIn) - { - this.worldObj = worldIn; - this.renderer = rendererIn; - for (int i = 0; i < this.fxLayers.length; ++i) - { - this.fxLayers[i] = Lists.newArrayList(); - } - this.registerParticles(); - } - - private void registerParticles() - { - this.register(ParticleType.EXPLOSION_NORMAL, new EntityExplodeFX.Factory()); - this.register(ParticleType.SPLASH, new EntitySplashFX.Factory()); - this.register(ParticleType.WATER_DROP, new EntityDownfallFX.RainFactory()); - this.register(ParticleType.DEPTH, new EntityAuraFX.SuspendFactory()); - this.register(ParticleType.CRIT, new EntityCritFX.Factory()); - this.register(ParticleType.SMOKE, new EntitySmokeFX.Factory()); - this.register(ParticleType.POTION, new EntitySpellParticleFX.Factory()); - this.register(ParticleType.GROW, new EntityAuraFX.GrowFactory()); - this.register(ParticleType.SPORE, new EntityAuraFX.Factory()); - this.register(ParticleType.TELEPORT, new EntityPortalFX.Factory()); - this.register(ParticleType.FLAME, new EntityFlameFX.Factory()); - this.register(ParticleType.LAVA, new EntityLavaFX.Factory()); - this.register(ParticleType.DUST, new EntityReddustFX.Factory()); - this.register(ParticleType.HEART, new EntityHeartFX.Factory()); - this.register(ParticleType.ITEM_CRACK, new EntityBreakingFX.Factory()); - this.register(ParticleType.BLOCK_CRACK, new EntityDiggingFX.Factory()); - this.register(ParticleType.EXPLOSION_HUGE, new EntityHugeExplodeFX.Factory()); - this.register(ParticleType.EXPLOSION_LARGE, new EntityTexturedFX.ExplodeFactory()); - this.register(ParticleType.HAIL_CORN, new EntityDownfallFX.HailFactory()); - } - - public void register(ParticleType id, IParticleFactory factory) - { - this.particleTypes.put(id, factory); - } - - public void spawnCritParticles(Entity entity) - { - this.addEffect(new EntityHitFX(entity)); - } - - /** - * Spawns the relevant particle according to the particle id. - * - * @param xCoord X position of the particle - * @param yCoord Y position of the particle - * @param zCoord Z position of the particle - * @param xSpeed X speed of the particle - * @param ySpeed Y speed of the particle - * @param zSpeed Z speed of the particle - * @param parameters Parameters for the particle (color for redstone, ...) - */ - public EntityFX spawnEffectParticle(ParticleType particleId, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int data) - { - IParticleFactory iparticlefactory = this.particleTypes.get(particleId); - - if (iparticlefactory != null) - { - EntityFX entityfx = iparticlefactory.getEntityFX(this.worldObj, xCoord, yCoord, zCoord, xSpeed, ySpeed, zSpeed, data); - - if (entityfx != null) - { - this.addEffect(entityfx); - return entityfx; - } - } - - return null; - } - - private void addEffect(EntityFX effect) - { - int i = effect.getFXLayer(); - if(this.fxLayers[i].size() >= 4000) - this.fxLayers[i].remove(0); - this.fxLayers[i].add(effect); - } - - public void updateEffects() - { - for (int i = 0; i < this.fxLayers.length; ++i) - { - this.updateEffectLayer(this.fxLayers[i]); - } - } - - private void updateEffectLayer(List entitiesFX) - { - List list = Lists.newArrayList(); - - for (int i = 0; i < entitiesFX.size(); ++i) - { - EntityFX entityfx = entitiesFX.get(i); - if (entityfx.onUpdate()) - list.add(entityfx); - } - - entitiesFX.removeAll(list); - } - - public void renderParticles(Entity entityIn, float partialTicks) - { - float f = MatrixState.getRotationX(); - float f1 = MatrixState.getRotationZ(); - float f2 = MatrixState.getRotationYZ(); - float f3 = MatrixState.getRotationXY(); - float f4 = MatrixState.getRotationXZ(); - EntityFX.interpPosX = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks; - EntityFX.interpPosY = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks; - EntityFX.interpPosZ = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks; - GlState.enableBlend(); - GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlState.alphaFunc(GL11.GL_GREATER, 0.003921569F); - - for (int i = 0; i < 2; ++i) - { - if (!this.fxLayers[i].isEmpty()) - { - GlState.depthMask(true); - - switch (i) - { - case 0: - default: - this.renderer.bindTexture(TEXTURE); - break; - - case 1: - this.renderer.bindTexture(TextureMap.BLOCKS); - } - - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); -// Tessellator tessellator = Tessellator.getInstance(); - RenderBuffer worldrenderer = Tessellator.getBuffer(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); - - for (int k = 0; k < this.fxLayers[i].size(); ++k) - { - final EntityFX entityfx = (EntityFX)this.fxLayers[i].get(k); - - entityfx.render(worldrenderer, partialTicks, f, f4, f1, f2, f3); - } - - Tessellator.draw(); - } - } - - GlState.depthMask(true); - GlState.disableBlend(); - GlState.alphaFunc(GL11.GL_GREATER, 0.1F); - } - - public void renderLitParticles(Entity entityIn, float partialTick) - { - float f = 0.017453292F; - float f1 = ExtMath.cos(entityIn.rotYaw * 0.017453292F); - float f2 = ExtMath.sin(entityIn.rotYaw * 0.017453292F); - float f3 = -f2 * ExtMath.sin(entityIn.rotPitch * 0.017453292F); - float f4 = f1 * ExtMath.sin(entityIn.rotPitch * 0.017453292F); - float f5 = ExtMath.cos(entityIn.rotPitch * 0.017453292F); - - List list = this.fxLayers[2]; - - if (!list.isEmpty()) - { - RenderBuffer worldrenderer = Tessellator.getBuffer(); - - for (int j = 0; j < list.size(); ++j) - { - EntityFX entityfx = list.get(j); - entityfx.render(worldrenderer, partialTick, f1, f5, f2, f3, f4); - } - } - } - - public void clearEffects(World worldIn) - { - this.worldObj = worldIn; - for (int i = 0; i < this.fxLayers.length; ++i) - { - this.fxLayers[i].clear(); - } - } - - public void addBlockDestroyEffects(BlockPos pos, State state) - { - if (state.getBlock() != Blocks.air) - { - state = state.getBlock().getActualState(state, this.worldObj, pos); - int i = 4; - - for (int j = 0; j < i; ++j) - { - for (int k = 0; k < i; ++k) - { - for (int l = 0; l < i; ++l) - { - 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.addEffect(new EntityDiggingFX(this.worldObj, d0, d1, d2, d0 - (double)pos.getX() - 0.5D, d1 - (double)pos.getY() - 0.5D, d2 - (double)pos.getZ() - 0.5D, state, pos, false)); - } - } - } - } - } - - /** - * Adds block hit particles for the specified block - */ - public void addBlockHitEffects(BlockPos pos, Facing side) - { - State iblockstate = this.worldObj.getState(pos); - Block block = iblockstate.getBlock(); - - if (block.getRenderType() != -1) - { - int i = pos.getX(); - int j = pos.getY(); - int k = pos.getZ(); - float f = 0.1F; - double d0 = (double)i + this.rand.doublev() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinX(); - double d1 = (double)j + this.rand.doublev() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinY(); - double d2 = (double)k + this.rand.doublev() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinZ(); - - if (side == Facing.DOWN) - { - d1 = (double)j + block.getBlockBoundsMinY() - (double)f; - } - - if (side == Facing.UP) - { - d1 = (double)j + block.getBlockBoundsMaxY() + (double)f; - } - - if (side == Facing.NORTH) - { - d2 = (double)k + block.getBlockBoundsMinZ() - (double)f; - } - - if (side == Facing.SOUTH) - { - d2 = (double)k + block.getBlockBoundsMaxZ() + (double)f; - } - - if (side == Facing.WEST) - { - d0 = (double)i + block.getBlockBoundsMinX() - (double)f; - } - - if (side == Facing.EAST) - { - d0 = (double)i + block.getBlockBoundsMaxX() + (double)f; - } - - this.addEffect(new EntityDiggingFX(this.worldObj, d0, d1, d2, 0.0D, 0.0D, 0.0D, iblockstate, pos, true)); - } - } - - public String getStatistics() - { - int i = 0; - for (int j = 0; j < 3; ++j) - { - i += this.fxLayers[j].size(); - } - return "" + i; - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityAuraFX.java b/client/src/main/java/client/renderer/particle/EntityAuraFX.java deleted file mode 100755 index 230dafa1..00000000 --- a/client/src/main/java/client/renderer/particle/EntityAuraFX.java +++ /dev/null @@ -1,73 +0,0 @@ -package client.renderer.particle; - -import common.world.World; - -public class EntityAuraFX extends EntityParticleFX -{ - private final boolean fullBright; - - protected EntityAuraFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double speedIn, boolean fullBright, int texture) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, speedIn); - float f = texture != 0 ? 1.0f : this.rand.floatv() * 0.1F + 0.2F; - this.red = f; - this.green = f; - this.blue = f; - this.setUV(texture != 0 ? 5 + texture : 0, texture != 0 ? 2 : 0); - this.scale *= this.rand.floatv() * 0.6F + 0.5F; - this.motionX *= 0.019999999552965164D; - this.motionY *= 0.019999999552965164D; - this.motionZ *= 0.019999999552965164D; - this.lifetime = (int)(20.0D / (Math.random() * 0.8D + 0.2D)); - this.fullBright = fullBright; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.99D; - this.motionY *= 0.99D; - this.motionZ *= 0.99D; - - if (this.lifetime-- <= 0) - { - return true; - } - return false; - } - - public int getBrightness(float partialTicks) - { - return this.fullBright ? 15728880 : super.getBrightness(partialTicks); - } - - public static class SuspendFactory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityAuraFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, true, 0); - } - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityAuraFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, false, 0); - } - } - - public static class GrowFactory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityAuraFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, false, 1); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityBreakingFX.java b/client/src/main/java/client/renderer/particle/EntityBreakingFX.java deleted file mode 100755 index d9d00f39..00000000 --- a/client/src/main/java/client/renderer/particle/EntityBreakingFX.java +++ /dev/null @@ -1,27 +0,0 @@ -package client.renderer.particle; - -import client.Client; -import common.init.ItemRegistry; -import common.item.Item; -import common.world.World; - -public class EntityBreakingFX extends EntityIconFX { - protected EntityBreakingFX(World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, Item item) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D, 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 static class Factory implements IParticleFactory { - public EntityFX getEntityFX(World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data) { - Item item = ItemRegistry.byId(data); - return item == null ? null : new EntityBreakingFX(world, x, y, z, xSpeed, ySpeed, zSpeed, item); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityCritFX.java b/client/src/main/java/client/renderer/particle/EntityCritFX.java deleted file mode 100755 index 18514ff0..00000000 --- a/client/src/main/java/client/renderer/particle/EntityCritFX.java +++ /dev/null @@ -1,77 +0,0 @@ -package client.renderer.particle; - -import common.util.ExtMath; -import common.world.World; - -public class EntityCritFX extends EntityParticleFX -{ - float field_174839_a; - - protected EntityCritFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i46284_8_, double p_i46284_10_, double p_i46284_12_) - { - this(worldIn, xCoordIn, yCoordIn, zCoordIn, p_i46284_8_, p_i46284_10_, p_i46284_12_, 1.0F); - } - - protected EntityCritFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i46285_8_, double p_i46285_10_, double p_i46285_12_, float p_i46285_14_) - { - super(worldIn, 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.blue = (float)(Math.random() * 0.30000001192092896D + 0.6000000238418579D); - this.red = this.blue * 0.3f; - this.green = this.blue * 0.8f; - this.scale *= 0.75F; - this.scale *= p_i46285_14_; - this.field_174839_a = this.scale; - this.lifetime = (int)(6.0D / (Math.random() * 0.8D + 0.6D)); - this.lifetime = (int)((float)this.lifetime * p_i46285_14_); - this.setUV(4, 2); - this.onUpdate(); - } - - /** - * Renders the particle - */ - protected void setScale(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; - f = ExtMath.clampf(f, 0.0F, 1.0F); - this.scale = this.field_174839_a * f; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.green = (float)((double)this.green * 0.96D); - this.blue = (float)((double)this.blue * 0.9D); - this.motionX *= 0.699999988079071D; - this.motionY *= 0.699999988079071D; - this.motionZ *= 0.699999988079071D; - this.motionY -= 0.019999999552965164D; - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityCritFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityDiggingFX.java b/client/src/main/java/client/renderer/particle/EntityDiggingFX.java deleted file mode 100755 index ca186547..00000000 --- a/client/src/main/java/client/renderer/particle/EntityDiggingFX.java +++ /dev/null @@ -1,46 +0,0 @@ -package client.renderer.particle; - -import client.Client; -import common.block.Block; -import common.init.BlockRegistry; -import common.init.Blocks; -import common.util.BlockPos; -import common.world.State; -import common.world.World; - -public class EntityDiggingFX extends EntityIconFX { - private final State state; - private final BlockPos position; - - protected EntityDiggingFX(World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, State state, BlockPos pos, boolean hit) { - super(world, x, y, z, xSpeed, ySpeed, zSpeed, hit ? 0.6f : 1.0f, Client.CLIENT.getBlockRendererDispatcher().getModelManager().getTexture(state)); - this.state = state; - this.gravity = 1.0F; - this.red = this.green = this.blue = 0.6F; - if(hit) { - this.motionX *= 0.2; - this.motionY = (this.motionY - 0.1) * 0.2 + 0.1; - this.motionZ *= 0.2; - } - this.position = pos == null ? new BlockPos(this.posX, this.posY, this.posZ) : pos; - Block block = this.state.getBlock(); - if(block == Blocks.grass) - return; - int color = pos == null ? block.getRenderColor(this.state) : block.colorMultiplier(this.world, pos); - this.red *= (float)(color >> 16 & 255) / 255.0F; - this.green *= (float)(color >> 8 & 255) / 255.0F; - this.blue *= (float)(color & 255) / 255.0F; - } - - public int getBrightness(float partial) { - int light = super.getBrightness(partial); - return light == 0 ? (this.world.isBlockLoaded(this.position) ? this.world.getCombinedLight(this.position, 0) : 0) : light; - } - - public static class Factory implements IParticleFactory { - public EntityFX getEntityFX(World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data) { - State state = BlockRegistry.byId(data); - return state == null ? null : new EntityDiggingFX(world, x, y, z, xSpeed, ySpeed, zSpeed, state, null, false); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityDownfallFX.java b/client/src/main/java/client/renderer/particle/EntityDownfallFX.java deleted file mode 100755 index e76b1704..00000000 --- a/client/src/main/java/client/renderer/particle/EntityDownfallFX.java +++ /dev/null @@ -1,90 +0,0 @@ -package client.renderer.particle; - -import common.block.Block; -import common.block.Material; -import common.block.liquid.BlockLiquid; -import common.util.BlockPos; -import common.util.ExtMath; -import common.world.State; -import common.world.World; - -public class EntityDownfallFX extends EntityParticleFX -{ - protected EntityDownfallFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, int texture) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); - this.motionX *= 0.30000001192092896D; - this.motionY = Math.random() * 0.20000000298023224D + 0.10000000149011612D; - this.motionZ *= 0.30000001192092896D; - this.red = 1.0F; - this.green = 1.0F; - this.blue = 1.0F; - this.setUV(this.rand.zrange(4), 1 + texture); - this.gravity = 0.06F; - this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - this.motionY -= (double)this.gravity; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - - if (this.lifetime-- <= 0) - { - return true; - } - - BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ); - State iblockstate = this.world.getState(blockpos); - Block block = iblockstate.getBlock(); - block.setBlockBoundsBasedOnState(this.world, blockpos); - Material material = iblockstate.getBlock().getMaterial(); - - if (material.isLiquid() || material.isSolid()) - { - double d0 = 0.0D; - - if (iblockstate.getBlock() instanceof BlockLiquid) - { - d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue())); - } - else - { - d0 = block.getBlockBoundsMaxY(); - } - - double d1 = (double)ExtMath.floord(this.posY) + d0; - - if (this.posY < d1) - { - return true; - } - } - return false; - } - - public static class RainFactory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityDownfallFX(worldIn, xCoordIn, yCoordIn, zCoordIn, 0); - } - } - - public static class HailFactory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityDownfallFX(worldIn, xCoordIn, yCoordIn, zCoordIn, 1); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityExplodeFX.java b/client/src/main/java/client/renderer/particle/EntityExplodeFX.java deleted file mode 100755 index b97518a2..00000000 --- a/client/src/main/java/client/renderer/particle/EntityExplodeFX.java +++ /dev/null @@ -1,48 +0,0 @@ -package client.renderer.particle; - -import common.world.World; - -public class EntityExplodeFX extends EntityParticleFX -{ - protected EntityExplodeFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) - { - super(worldIn, 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; - this.red = this.green = this.blue = this.rand.floatv() * 0.3F + 0.7F; - this.scale = this.rand.floatv() * this.rand.floatv() * 6.0F + 1.0F; - this.lifetime = (int)(16.0D / ((double)this.rand.floatv() * 0.8D + 0.2D)) + 2; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 0); - this.motionY += 0.004D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.8999999761581421D; - this.motionY *= 0.8999999761581421D; - this.motionZ *= 0.8999999761581421D; - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityExplodeFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityFX.java b/client/src/main/java/client/renderer/particle/EntityFX.java deleted file mode 100755 index f709fce0..00000000 --- a/client/src/main/java/client/renderer/particle/EntityFX.java +++ /dev/null @@ -1,19 +0,0 @@ -package client.renderer.particle; - -import client.renderer.RenderBuffer; -import common.rng.Random; - -public abstract class EntityFX { - static double interpPosX; - static double interpPosY; - static double interpPosZ; - - protected final Random rand = new Random(); - - 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 getFXLayer(); -} diff --git a/client/src/main/java/client/renderer/particle/EntityFlameFX.java b/client/src/main/java/client/renderer/particle/EntityFlameFX.java deleted file mode 100755 index b6741040..00000000 --- a/client/src/main/java/client/renderer/particle/EntityFlameFX.java +++ /dev/null @@ -1,80 +0,0 @@ -package client.renderer.particle; - -import common.util.ExtMath; -import common.world.World; - -public class EntityFlameFX extends EntityParticleFX -{ - /** the scale of the flame FX */ - private float flameScale; - - protected EntityFlameFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) - { - super(worldIn, 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; - this.posX += (double)((this.rand.floatv() - this.rand.floatv()) * 0.05F); - this.posY += (double)((this.rand.floatv() - this.rand.floatv()) * 0.05F); - this.posZ += (double)((this.rand.floatv() - this.rand.floatv()) * 0.05F); - this.flameScale = this.scale; - this.red = this.green = this.blue = 1.0F; - this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)) + 4; - this.setUV(6, 1); - } - - /** - * Renders the particle - */ - protected void setScale(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime; - this.scale = this.flameScale * (1.0F - f * f * 0.5F); - } - - public int getBrightness(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime; - f = ExtMath.clampf(f, 0.0F, 1.0F); - int i = super.getBrightness(partialTicks); - int j = i & 255; - int k = i >> 16 & 255; - j = j + (int)(f * 15.0F * 16.0F); - - if (j > 240) - { - j = 240; - } - - return j | k << 16; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9599999785423279D; - this.motionY *= 0.9599999785423279D; - this.motionZ *= 0.9599999785423279D; - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityFlameFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityHeartFX.java b/client/src/main/java/client/renderer/particle/EntityHeartFX.java deleted file mode 100755 index 7620e374..00000000 --- a/client/src/main/java/client/renderer/particle/EntityHeartFX.java +++ /dev/null @@ -1,85 +0,0 @@ -package client.renderer.particle; - -import common.util.ExtMath; -import common.world.World; - -public class EntityHeartFX extends EntityParticleFX -{ - float particleScaleOverTime; - - protected EntityHeartFX(World worldIn, double p_i1211_2_, double p_i1211_4_, double p_i1211_6_, double p_i1211_8_, double p_i1211_10_, double p_i1211_12_) - { - this(worldIn, p_i1211_2_, p_i1211_4_, p_i1211_6_, p_i1211_8_, p_i1211_10_, p_i1211_12_, 2.0F); - } - - protected EntityHeartFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i46354_8_, double p_i46354_10_, double p_i46354_12_, float scale) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); - this.motionX *= 0.009999999776482582D; - this.motionY *= 0.009999999776482582D; - this.motionZ *= 0.009999999776482582D; - this.motionY += 0.1D; - this.scale *= 0.75F; - this.scale *= scale; - this.particleScaleOverTime = this.scale; - this.lifetime = 16; - this.setUV(5, 2); - } - - /** - * Renders the particle - */ - protected void setScale(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; - f = ExtMath.clampf(f, 0.0F, 1.0F); - this.scale = this.particleScaleOverTime * f; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - this.moveEntity(this.motionX, this.motionY, this.motionZ); - - if (this.posY == this.prevY) - { - this.motionX *= 1.1D; - this.motionZ *= 1.1D; - } - - this.motionX *= 0.8600000143051147D; - this.motionY *= 0.8600000143051147D; - this.motionZ *= 0.8600000143051147D; - return false; - } - -// public static class AngryVillagerFactory implements IParticleFactory -// { -// public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_) -// { -// EntityFX entityfx = new EntityHeartFX(worldIn, xCoordIn, yCoordIn + 0.5D, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); -// entityfx.setParticleTextureIndex(81); -// entityfx.setRBGColorF(1.0F, 1.0F, 1.0F); -// return entityfx; -// } -// } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityHeartFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityHitFX.java b/client/src/main/java/client/renderer/particle/EntityHitFX.java deleted file mode 100755 index 1167d891..00000000 --- a/client/src/main/java/client/renderer/particle/EntityHitFX.java +++ /dev/null @@ -1,25 +0,0 @@ -package client.renderer.particle; - -import common.entity.Entity; -import common.model.ParticleType; - -public class EntityHitFX extends EntityTickedFX { - private final Entity entity; - - public EntityHitFX(Entity entity) { - super(16, 3); - this.entity = entity; - this.onUpdate(); - } - - public void spawnParticle() { - double x = (double)(this.rand.floatv() * 2.0F - 1.0F); - double y = (double)(this.rand.floatv() * 2.0F - 1.0F); - double z = (double)(this.rand.floatv() * 2.0F - 1.0F); - if(x * x + y * y + z * z <= 1.0D) { - this.entity.worldObj.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); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityHugeExplodeFX.java b/client/src/main/java/client/renderer/particle/EntityHugeExplodeFX.java deleted file mode 100755 index 2dac2a8c..00000000 --- a/client/src/main/java/client/renderer/particle/EntityHugeExplodeFX.java +++ /dev/null @@ -1,32 +0,0 @@ -package client.renderer.particle; - -import common.model.ParticleType; -import common.world.World; - -public class EntityHugeExplodeFX extends EntityTickedFX { - private final World world; - private final double posX; - private final double posY; - private final double posZ; - - protected EntityHugeExplodeFX(World world, double x, double y, double z) { - super(6, 8); - this.world = world; - this.posX = x; - this.posY = y; - this.posZ = z; - } - - public void spawnParticle() { - double x = this.posX + (this.rand.doublev() - this.rand.doublev()) * 4.0D; - double y = this.posY + (this.rand.doublev() - this.rand.doublev()) * 4.0D; - double z = this.posZ + (this.rand.doublev() - this.rand.doublev()) * 4.0D; - this.world.spawnParticle(ParticleType.EXPLOSION_LARGE, x, y, z, (double)((float)this.age / (float)this.lifetime), 0.0D, 0.0D); - } - - public static class Factory implements IParticleFactory { - public EntityFX getEntityFX(World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data) { - return new EntityHugeExplodeFX(world, x, y, z); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityIconFX.java b/client/src/main/java/client/renderer/particle/EntityIconFX.java deleted file mode 100644 index 74716712..00000000 --- a/client/src/main/java/client/renderer/particle/EntityIconFX.java +++ /dev/null @@ -1,65 +0,0 @@ -package client.renderer.particle; - -import client.renderer.RenderBuffer; -import client.renderer.texture.TextureAtlasSprite; -import common.world.World; - -public class EntityIconFX extends EntityWorldFX { - private final TextureAtlasSprite icon; - private final float offsetX; - private final float offsetY; - private final float size; - - protected float red; - protected float green; - protected float blue; - - protected EntityIconFX(World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, float size, - TextureAtlasSprite icon) { - super(world, x, y, z, xSpeed, ySpeed, zSpeed); - this.size = (this.rand.floatv() * 0.5F + 0.5F) * size * 0.1f; - this.icon = icon; - this.offsetX = this.rand.floatv() * 3.0F; - this.offsetY = this.rand.floatv() * 3.0F; - } - - public final int getFXLayer() { - return 1; - } - - public final void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ) { - float u1 = this.icon.getInterpolatedU((double)(this.offsetX * 4.0F)); - float u2 = this.icon.getInterpolatedU((double)((this.offsetX + 1.0F) * 4.0F)); - float v1 = this.icon.getInterpolatedV((double)(this.offsetY * 4.0F)); - float v2 = this.icon.getInterpolatedV((double)((this.offsetY + 1.0F) * 4.0F)); - float scale = this.size; - 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)u1, (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)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)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)u2, (double)v2).color(this.red, this.green, this.blue, 1.0F).lightmap(sky, block).endVertex(); - } - - public final boolean onUpdate() { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - if(this.age++ >= this.lifetime) - return true; - this.motionY -= 0.04D * (double)this.gravity; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - return false; - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityLavaFX.java b/client/src/main/java/client/renderer/particle/EntityLavaFX.java deleted file mode 100755 index 8af33220..00000000 --- a/client/src/main/java/client/renderer/particle/EntityLavaFX.java +++ /dev/null @@ -1,80 +0,0 @@ -package client.renderer.particle; - -import common.model.ParticleType; -import common.util.ExtMath; -import common.world.World; - -public class EntityLavaFX extends EntityParticleFX -{ - private float lavaParticleScale; - - protected EntityLavaFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); - this.motionX *= 0.800000011920929D; - this.motionY *= 0.800000011920929D; - this.motionZ *= 0.800000011920929D; - this.motionY = (double)(this.rand.floatv() * 0.4F + 0.05F); - this.red = this.green = this.blue = 1.0F; - this.scale *= this.rand.floatv() * 2.0F + 0.2F; - this.lavaParticleScale = this.scale; - this.lifetime = (int)(16.0D / (Math.random() * 0.8D + 0.2D)); - this.setUV(7, 1); - } - - public int getBrightness(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime; - f = ExtMath.clampf(f, 0.0F, 1.0F); - int i = super.getBrightness(partialTicks); - int j = 240; - int k = i >> 16 & 255; - return j | k << 16; - } - - /** - * Renders the particle - */ - protected void setScale(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime; - this.scale = this.lavaParticleScale * (1.0F - f * f); - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - float f = (float)this.age / (float)this.lifetime; - - if (this.rand.floatv() > f) - { - this.world.spawnParticle(ParticleType.SMOKE, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ); - } - - this.motionY -= 0.03D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9990000128746033D; - this.motionY *= 0.9990000128746033D; - this.motionZ *= 0.9990000128746033D; - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityLavaFX(worldIn, xCoordIn, yCoordIn, zCoordIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityParticleFX.java b/client/src/main/java/client/renderer/particle/EntityParticleFX.java deleted file mode 100644 index 88e6a54a..00000000 --- a/client/src/main/java/client/renderer/particle/EntityParticleFX.java +++ /dev/null @@ -1,54 +0,0 @@ -package client.renderer.particle; - -import client.renderer.RenderBuffer; -import common.world.World; - -public abstract class EntityParticleFX extends EntityWorldFX { - private int textureU; - private int textureV; - protected float scale; - protected float red; - protected float green; - protected float blue; - - public EntityParticleFX(World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - super(world, x, y, z, xSpeed, ySpeed, zSpeed); - this.red = this.green = this.blue = 1.0F; - this.scale = (this.rand.floatv() * 0.5F + 0.5F) * 2.0F; - } - - protected void setScale(float partial) { - } - - 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(); - } - - public final int getFXLayer() { - return 0; - } - - protected final void setUV(int x, int y) { - this.textureU = x; - this.textureV = y; - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityPortalFX.java b/client/src/main/java/client/renderer/particle/EntityPortalFX.java deleted file mode 100755 index 5fdd8069..00000000 --- a/client/src/main/java/client/renderer/particle/EntityPortalFX.java +++ /dev/null @@ -1,90 +0,0 @@ -package client.renderer.particle; - -import common.world.World; - -public class EntityPortalFX extends EntityParticleFX -{ - private float portalParticleScale; - private double portalPosX; - private double portalPosY; - private double portalPosZ; - - protected EntityPortalFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - this.motionX = xSpeedIn; - this.motionY = ySpeedIn; - this.motionZ = zSpeedIn; - this.portalPosX = this.posX = xCoordIn; - this.portalPosY = this.posY = yCoordIn; - this.portalPosZ = this.posZ = zCoordIn; - float f = this.rand.floatv() * 0.6F + 0.4F; - this.portalParticleScale = this.scale = this.rand.floatv() * 0.2F + 0.5F; - this.red = this.green = this.blue = 1.0F * f; - this.green *= 0.1F; - this.red *= 0.2F; - this.blue *= 0.25F; - this.lifetime = (int)(Math.random() * 10.0D) + 40; - this.setUV((int)(Math.random() * 8.0D), 0); - } - - /** - * Renders the particle - */ - protected void setScale(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime; - f = 1.0F - f; - f = f * f; - f = 1.0F - f; - this.scale = this.portalParticleScale * f; - } - - public int getBrightness(float partialTicks) - { - int i = super.getBrightness(partialTicks); - float f = (float)this.age / (float)this.lifetime; - f = f * f; - f = f * f; - int j = i & 255; - int k = i >> 16 & 255; - k = k + (int)(f * 15.0F * 16.0F); - - if (k > 240) - { - k = 240; - } - - return j | k << 16; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - float f = (float)this.age / (float)this.lifetime; - f = -f + f * f * 2.0F; - f = 1.0F - f; - this.posX = this.portalPosX + this.motionX * (double)f; - this.posY = this.portalPosY + this.motionY * (double)f + (double)(1.0F - f); - this.posZ = this.portalPosZ + this.motionZ * (double)f; - - if (this.age++ >= this.lifetime) - { - return true; - } - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityPortalFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityReddustFX.java b/client/src/main/java/client/renderer/particle/EntityReddustFX.java deleted file mode 100755 index 9119e488..00000000 --- a/client/src/main/java/client/renderer/particle/EntityReddustFX.java +++ /dev/null @@ -1,84 +0,0 @@ -package client.renderer.particle; - -import common.util.ExtMath; -import common.world.World; - -public class EntityReddustFX extends EntityParticleFX -{ - float reddustParticleScale; - - protected EntityReddustFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, float p_i46349_8_, float p_i46349_9_, float p_i46349_10_) - { - this(worldIn, xCoordIn, yCoordIn, zCoordIn, 1.0F, p_i46349_8_, p_i46349_9_, p_i46349_10_); - } - - protected EntityReddustFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, float p_i46350_8_, float p_i46350_9_, float p_i46350_10_, float p_i46350_11_) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); - this.motionX *= 0.10000000149011612D; - this.motionY *= 0.10000000149011612D; - this.motionZ *= 0.10000000149011612D; - - if (p_i46350_9_ == 0.0F) - { - p_i46350_9_ = 1.0F; - } - - float f = (float)Math.random() * 0.4F + 0.6F; - this.red = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * p_i46350_9_ * f; - this.green = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * p_i46350_10_ * f; - this.blue = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * p_i46350_11_ * f; - this.scale *= 0.75F; - this.scale *= p_i46350_8_; - this.reddustParticleScale = this.scale; - this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); - this.lifetime = (int)((float)this.lifetime * p_i46350_8_); - } - - /** - * Renders the particle - */ - protected void setScale(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; - f = ExtMath.clampf(f, 0.0F, 1.0F); - this.scale = this.reddustParticleScale * f; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 0); - this.moveEntity(this.motionX, this.motionY, this.motionZ); - - if (this.posY == this.prevY) - { - this.motionX *= 1.1D; - this.motionZ *= 1.1D; - } - - this.motionX *= 0.9599999785423279D; - this.motionY *= 0.9599999785423279D; - this.motionZ *= 0.9599999785423279D; - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntityReddustFX(worldIn, xCoordIn, yCoordIn, zCoordIn, (float)xSpeedIn, (float)ySpeedIn, (float)zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntitySmokeFX.java b/client/src/main/java/client/renderer/particle/EntitySmokeFX.java deleted file mode 100755 index 07008604..00000000 --- a/client/src/main/java/client/renderer/particle/EntitySmokeFX.java +++ /dev/null @@ -1,79 +0,0 @@ -package client.renderer.particle; - -import common.util.ExtMath; -import common.world.World; - -public class EntitySmokeFX extends EntityParticleFX -{ - float smokeParticleScale; - - private EntitySmokeFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i46347_8_, double p_i46347_10_, double p_i46347_12_) - { - this(worldIn, xCoordIn, yCoordIn, zCoordIn, p_i46347_8_, p_i46347_10_, p_i46347_12_, 1.0F); - } - - protected EntitySmokeFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i46348_8_, double p_i46348_10_, double p_i46348_12_, float p_i46348_14_) - { - super(worldIn, 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.scale *= p_i46348_14_; - this.smokeParticleScale = this.scale; - this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); - this.lifetime = (int)((float)this.lifetime * p_i46348_14_); - } - - /** - * Renders the particle - */ - protected void setScale(float partialTicks) - { - float f = ((float)this.age + partialTicks) / (float)this.lifetime * 32.0F; - f = ExtMath.clampf(f, 0.0F, 1.0F); - this.scale = this.smokeParticleScale * f; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 0); - this.motionY += 0.004D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - - if (this.posY == this.prevY) - { - this.motionX *= 1.1D; - this.motionZ *= 1.1D; - } - - this.motionX *= 0.9599999785423279D; - this.motionY *= 0.9599999785423279D; - this.motionZ *= 0.9599999785423279D; - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntitySmokeFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntitySpellParticleFX.java b/client/src/main/java/client/renderer/particle/EntitySpellParticleFX.java deleted file mode 100755 index 42b9e881..00000000 --- a/client/src/main/java/client/renderer/particle/EntitySpellParticleFX.java +++ /dev/null @@ -1,73 +0,0 @@ -package client.renderer.particle; - -import common.rng.Random; -import common.world.World; - -public class EntitySpellParticleFX extends EntityParticleFX -{ - private static final Random RANDOM = new Random(); - - protected EntitySpellParticleFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i1229_8_, double p_i1229_10_, double p_i1229_12_) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.5D - RANDOM.doublev(), p_i1229_10_, 0.5D - RANDOM.doublev()); - this.motionY *= 0.20000000298023224D; - - if (p_i1229_8_ == 0.0D && p_i1229_12_ == 0.0D) - { - this.motionX *= 0.10000000149011612D; - this.motionZ *= 0.10000000149011612D; - } - - this.scale *= 0.75F; - this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); - } - - public void setParameter(float particleRedIn, float particleGreenIn, float particleBlueIn, float multiplier) - { - this.motionX *= (double)multiplier; - this.motionY = (this.motionY - 0.10000000149011612D) * (double)multiplier + 0.10000000149011612D; - this.motionZ *= (double)multiplier; - float f3 = 0.75F + this.rand.floatv() * 0.25F; - this.red = particleRedIn * f3; - this.green = particleGreenIn * f3; - this.blue = particleBlueIn * f3; - } - - /** - * Called to update the entity's position/logic. - */ - public boolean onUpdate() - { - this.prevX = this.posX; - this.prevY = this.posY; - this.prevZ = this.posZ; - - if (this.age++ >= this.lifetime) - { - return true; - } - - this.setUV(Math.max(0, 7 - this.age * 8 / this.lifetime), 3); - this.motionY += 0.004D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - - if (this.posY == this.prevY) - { - this.motionX *= 1.1D; - this.motionZ *= 1.1D; - } - - this.motionX *= 0.9599999785423279D; - this.motionY *= 0.9599999785423279D; - this.motionZ *= 0.9599999785423279D; - return false; - } - - public static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntitySpellParticleFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntitySplashFX.java b/client/src/main/java/client/renderer/particle/EntitySplashFX.java deleted file mode 100755 index bfb6d3a7..00000000 --- a/client/src/main/java/client/renderer/particle/EntitySplashFX.java +++ /dev/null @@ -1,28 +0,0 @@ -package client.renderer.particle; - -import common.world.World; - -public class EntitySplashFX extends EntityDownfallFX -{ - protected EntitySplashFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) - { - super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0); - this.gravity = 0.04F; - this.setUV(1 + this.rand.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 static class Factory implements IParticleFactory - { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data) - { - return new EntitySplashFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityTexturedFX.java b/client/src/main/java/client/renderer/particle/EntityTexturedFX.java deleted file mode 100644 index 67f34423..00000000 --- a/client/src/main/java/client/renderer/particle/EntityTexturedFX.java +++ /dev/null @@ -1,90 +0,0 @@ -package client.renderer.particle; - -import org.lwjgl.opengl.GL11; - -import client.Client; -import client.renderer.DefaultVertexFormats; -import client.renderer.GlState; -import client.renderer.ItemRenderer; -import client.renderer.RenderBuffer; -import client.renderer.Tessellator; -import client.renderer.VertexFormat; -import client.renderer.texture.TextureManager; -import common.world.World; - -public class EntityTexturedFX extends EntityFX { - 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 float scale; - private final float brightness; - private final double posX; - private final double posY; - private final double posZ; - - private int age; - private int lifetime; - private TextureManager manager; - - protected EntityTexturedFX(TextureManager manager, double x, double y, double z, double scale, String texture) { - this.manager = manager; - this.lifetime = 6 + this.rand.zrange(4); - this.brightness = this.rand.floatv() * 0.6F + 0.4F; - this.scale = (float)scale; - this.texture = texture; - 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) { - 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); - 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) - .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) - .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).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).normal(0.0F, 1.0F, 0.0F).endVertex(); - Tessellator.draw(); - GlState.enableLighting(); - } - } - - public final boolean onUpdate() { - if(++this.age >= this.lifetime) - return true; - return false; - } - - public final int getFXLayer() { - return 2; - } - - public static class ExplodeFactory implements IParticleFactory { - public EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, - double zSpeedIn, int data) { - return new EntityTexturedFX(Client.CLIENT.getTextureManager(), xCoordIn, yCoordIn, zCoordIn, xSpeedIn, "textures/entity/explosion.png"); - } - } -} diff --git a/client/src/main/java/client/renderer/particle/EntityTickedFX.java b/client/src/main/java/client/renderer/particle/EntityTickedFX.java deleted file mode 100644 index 93831fb8..00000000 --- a/client/src/main/java/client/renderer/particle/EntityTickedFX.java +++ /dev/null @@ -1,30 +0,0 @@ -package client.renderer.particle; - -import client.renderer.RenderBuffer; - -public abstract class EntityTickedFX extends EntityFX { - private final int amount; - - protected EntityTickedFX(int amount, int lifetime) { - this.amount = amount; - this.lifetime = lifetime; - } - - public final boolean onUpdate() { - for(int z = 0; z < this.amount; z++) { - this.spawnParticle(); - } - if(++this.age >= this.lifetime) - return true; - return false; - } - - public final int getFXLayer() { - return 3; - } - - public final void render(RenderBuffer rb, float partial, float rotX, float rotZ, float rotYZ, float rotXY, float rotXZ) { - } - - protected abstract void spawnParticle(); -} diff --git a/client/src/main/java/client/renderer/particle/EntityWorldFX.java b/client/src/main/java/client/renderer/particle/EntityWorldFX.java deleted file mode 100644 index c3cbbc8c..00000000 --- a/client/src/main/java/client/renderer/particle/EntityWorldFX.java +++ /dev/null @@ -1,58 +0,0 @@ -package client.renderer.particle; - -import common.util.BlockPos; -import common.util.ExtMath; -import common.world.World; - -public abstract class EntityWorldFX extends EntityFX -{ - protected final World world; - - protected double prevX; - protected double prevY; - protected double prevZ; - protected double posX; - protected double posY; - protected double posZ; - protected double motionX; - protected double motionY; - protected double motionZ; - - protected float gravity; - - protected EntityWorldFX(World worldIn, double posXIn, double posYIn, double posZIn) - { - this.world = worldIn; - this.posX = this.prevX = posXIn; - this.posY = this.prevY = posYIn; - this.posZ = this.prevZ = posZIn; - this.lifetime = (int)(4.0F / (this.rand.floatv() * 0.9F + 0.1F)); - this.age = 0; - } - - public EntityWorldFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) - { - this(worldIn, xCoordIn, yCoordIn, zCoordIn); - this.motionX = xSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D; - this.motionY = ySpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D; - this.motionZ = zSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D; - float f = (float)(Math.random() + Math.random() + 1.0D) * 0.15F; - float f1 = ExtMath.sqrtd(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - this.motionX = this.motionX / (double)f1 * (double)f * 0.4000000059604645D; - this.motionY = this.motionY / (double)f1 * (double)f * 0.4000000059604645D + 0.10000000149011612D; - this.motionZ = this.motionZ / (double)f1 * (double)f * 0.4000000059604645D; - } - - public final void moveEntity(double x, double y, double z) - { - this.posX += x; - this.posY += y; - this.posZ += z; - } - - public int getBrightness(float partial) - { - BlockPos pos = new BlockPos(this.posX, this.posY, this.posZ); - return this.world.isBlockLoaded(pos) ? this.world.getCombinedLight(pos, 0) : 0; - } -} diff --git a/client/src/main/java/client/renderer/particle/IParticleFactory.java b/client/src/main/java/client/renderer/particle/IParticleFactory.java deleted file mode 100755 index 534606ab..00000000 --- a/client/src/main/java/client/renderer/particle/IParticleFactory.java +++ /dev/null @@ -1,8 +0,0 @@ -package client.renderer.particle; - -import common.world.World; - -public interface IParticleFactory -{ - EntityFX getEntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int data); -} diff --git a/client/src/main/java/client/world/WorldClient.java b/client/src/main/java/client/world/WorldClient.java index d5662bfe..aaad5edb 100755 --- a/client/src/main/java/client/world/WorldClient.java +++ b/client/src/main/java/client/world/WorldClient.java @@ -4,8 +4,6 @@ import java.util.List; import java.util.Set; import client.Client; -import client.renderer.particle.EntityFX; -import client.renderer.particle.EntitySpellParticleFX; import common.biome.Biome; import common.collect.Lists; import common.collect.Sets; @@ -19,7 +17,6 @@ import common.init.ItemRegistry; import common.init.Items; import common.init.SoundEvent; import common.item.material.ItemDye; -import common.item.tool.ItemPotion; import common.log.Log; import common.model.ParticleType; import common.rng.Random; @@ -417,39 +414,16 @@ public class WorldClient extends AWorldClient // zOffset, data); // } - public void spawnParticle(ParticleType particleType, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, + public void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int data) { - this.spawnEntityFX(particleType, particleType.isUnlimited(), xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, data); - } - - public EntityFX spawnEntityFX(ParticleType particle, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int data) - { if (this.gm.getRenderViewEntity() != null) { -// int i = this.gm.particleSetting; -// -// if (i == 1 && this.rand.zrange(3) == 0) -// { -// i = 2; -// } - double d0 = this.gm.getRenderViewEntity().posX - xCoord; double d1 = this.gm.getRenderViewEntity().posY - yCoord; double d2 = this.gm.getRenderViewEntity().posZ - zCoord; - - if (ignoreRange) - { - return this.gm.effectRenderer.spawnEffectParticle(particle, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, data); - } - else - { - double d3 = 16.0D; - if(d0 * d0 + d1 * d1 + d2 * d2 > 256.0D) - return null; - return this.gm.effectRenderer.spawnEffectParticle(particle, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, data); - } + if(particle.isUnlimited() || d0 * d0 + d1 * d1 + d2 * d2 <= 256.0D) + this.gm.effectRenderer.spawnParticle(particle, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, data); } - return null; } // public void broadcastSound(int soundID, BlockPos pos, int data) @@ -636,7 +610,7 @@ public class WorldClient extends AWorldClient this.gm.getSoundManager().playSound(new PositionedSound(state.getBlock().sound.getBreakSound(), 1.0F, /* block.sound.getFrequency() * 0.8F, */ (float)blockPosIn.getX() + 0.5F, (float)blockPosIn.getY() + 0.5F, (float)blockPosIn.getZ() + 0.5F)); } if(state != null) - this.gm.effectRenderer.addBlockDestroyEffects(blockPosIn, state); + this.gm.effectRenderer.destroyBlock(blockPosIn, state); break; case 2002: @@ -649,30 +623,9 @@ public class WorldClient extends AWorldClient 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.potion)); } - float f = 1.0F; - float f1 = 1.0F; - float f2 = 1.0F; - if((data & 16383) != 0) { - ItemPotion potion = ItemPotion.getPotionItem(data); - int j1 = potion.getColorFromDamage(); - f = (float)(j1 >> 16 & 255) / 255.0F; - f1 = (float)(j1 >> 8 & 255) / 255.0F; - f2 = (float)(j1 >> 0 & 255) / 255.0F; - } - for (int l1 = 0; l1 < 100; ++l1) { - double d22 = this.rand.doublev() * 4.0D; - double d23 = this.rand.doublev() * Math.PI * 2.0D; - double d24 = Math.cos(d23) * d22; - double d9 = 0.01D + this.rand.doublev() * 0.5D; - double d11 = Math.sin(d23) * d22; - EntityFX entityfx = this.spawnEntityFX(ParticleType.POTION, ParticleType.POTION.isUnlimited(), d13 + d24 * 0.1D, d14 + 0.3D, d16 + d11 * 0.1D, d24, d9, d11, 0); - - if (entityfx instanceof EntitySpellParticleFX spell) - { - spell.setParameter(f, f1, f2, (float)d22); - } + this.spawnParticle(ParticleType.POTION, d13, d14, d16, 0.0, 0.0, 0.0, data); } this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F); diff --git a/common/src/main/java/common/block/natural/BlockRedstoneOre.java b/common/src/main/java/common/block/natural/BlockRedstoneOre.java index 3158be61..b6c730d0 100755 --- a/common/src/main/java/common/block/natural/BlockRedstoneOre.java +++ b/common/src/main/java/common/block/natural/BlockRedstoneOre.java @@ -171,7 +171,7 @@ public class BlockRedstoneOre extends Block if (d1 < (double)pos.getX() || d1 > (double)(pos.getX() + 1) || d2 < 0.0D || d2 > (double)(pos.getY() + 1) || d3 < (double)pos.getZ() || d3 > (double)(pos.getZ() + 1)) { - worldIn.spawnParticle(ParticleType.DUST, d1, d2, d3, 0.0D, 0.0D, 0.0D); + worldIn.spawnParticle(ParticleType.DUST, d1, d2, d3, 1.0D, 0.0D, 0.0D); } } } diff --git a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java index 3069b071..cf86f17a 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java @@ -126,7 +126,7 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode f = f / 16.0F; double d3 = (double)(f * (float)enumfacing.getFrontOffsetX()); double d4 = (double)(f * (float)enumfacing.getFrontOffsetZ()); - worldIn.spawnParticle(ParticleType.DUST, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); + worldIn.spawnParticle(ParticleType.DUST, d0 + d3, d1, d2 + d4, 1.0D, 0.0D, 0.0D); } } diff --git a/common/src/main/java/common/block/tech/BlockRedstoneTorch.java b/common/src/main/java/common/block/tech/BlockRedstoneTorch.java index 02f9826c..a37d7a8d 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneTorch.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneTorch.java @@ -206,7 +206,7 @@ public class BlockRedstoneTorch extends BlockTorch d2 += 0.27D * (double)enumfacing1.getFrontOffsetZ(); } - worldIn.spawnParticle(ParticleType.DUST, d0, d1, d2, 0.0D, 0.0D, 0.0D); + worldIn.spawnParticle(ParticleType.DUST, d0, d1, d2, 1.0D, 0.0D, 0.0D); } } diff --git a/common/src/main/java/common/packet/SPacketParticles.java b/common/src/main/java/common/packet/SPacketParticles.java index 476888bb..1da6682a 100755 --- a/common/src/main/java/common/packet/SPacketParticles.java +++ b/common/src/main/java/common/packet/SPacketParticles.java @@ -18,17 +18,15 @@ public class SPacketParticles implements Packet private float zOffset; private float particleSpeed; private int particleCount; - private boolean longDistance; private int particleArgument; public SPacketParticles() { } - public SPacketParticles(ParticleType particleTypeIn, boolean longDistanceIn, float x, float y, float z, float xOffsetIn, float yOffset, float zOffset, float particleSpeedIn, int particleCountIn, int particleArgumentIn) + public SPacketParticles(ParticleType particleTypeIn, float x, float y, float z, float xOffsetIn, float yOffset, float zOffset, float particleSpeedIn, int particleCountIn, int particleArgumentIn) { this.particleType = particleTypeIn; - this.longDistance = longDistanceIn; this.xCoord = x; this.yCoord = y; this.zCoord = z; @@ -46,7 +44,6 @@ public class SPacketParticles implements Packet public void readPacketData(PacketBuffer buf) throws IOException { this.particleType = buf.readEnumValue(ParticleType.class); - this.longDistance = buf.readBoolean(); this.xCoord = buf.readFloat(); this.yCoord = buf.readFloat(); this.zCoord = buf.readFloat(); @@ -64,7 +61,6 @@ public class SPacketParticles implements Packet public void writePacketData(PacketBuffer buf) throws IOException { buf.writeEnumValue(this.particleType); - buf.writeBoolean(this.longDistance); buf.writeFloat(this.xCoord); buf.writeFloat(this.yCoord); buf.writeFloat(this.zCoord); @@ -81,11 +77,6 @@ public class SPacketParticles implements Packet return this.particleType; } - public boolean isLongDistance() - { - return this.longDistance; - } - /** * Gets the x coordinate to spawn the particle. */ diff --git a/server/src/main/java/server/command/commands/CommandEffect.java b/server/src/main/java/server/command/commands/CommandEffect.java index 58fa4e50..477e4172 100644 --- a/server/src/main/java/server/command/commands/CommandEffect.java +++ b/server/src/main/java/server/command/commands/CommandEffect.java @@ -27,7 +27,7 @@ public class CommandEffect extends Command { public void exec(CommandEnvironment env, Executor exec, List players, ParticleType type, Vec3 pos, Vec3 offset, double speed, int count) { offset = offset == null ? new Vec3(0.0, 0.0, 0.0) : offset; for(Player player : players) { - player.sendPacket(new SPacketParticles(type, true, (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, (float)offset.xCoord, (float)offset.yCoord, (float)offset.zCoord, (float)speed, count, 0)); + player.sendPacket(new SPacketParticles(type, (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, (float)offset.xCoord, (float)offset.yCoord, (float)offset.zCoord, (float)speed, count, 0)); } } } diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index 7e267e31..ab85e218 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -1287,15 +1287,9 @@ public final class WorldServer extends AWorldServer { // this.resetWeather = false; } - public void spawnParticle(ParticleType particleType, double xCoord, double yCoord, double zCoord, int numberOfParticles, double xOffset, - double yOffset, double zOffset, double particleSpeed, int data) { - this.spawnParticle(particleType, false, xCoord, yCoord, zCoord, numberOfParticles, xOffset, yOffset, zOffset, particleSpeed, - data); - } - - public void spawnParticle(ParticleType particleType, boolean longDistance, double xCoord, double yCoord, double zCoord, + public void spawnParticle(ParticleType particleType, double xCoord, double yCoord, double zCoord, int numberOfParticles, double xOffset, double yOffset, double zOffset, double particleSpeed, int data) { - Packet packet = new SPacketParticles(particleType, longDistance, (float)xCoord, (float)yCoord, (float)zCoord, (float)xOffset, + Packet packet = new SPacketParticles(particleType, (float)xCoord, (float)yCoord, (float)zCoord, (float)xOffset, (float)yOffset, (float)zOffset, (float)particleSpeed, numberOfParticles, data); for(int i = 0; i < this.players.size(); ++i) { @@ -1303,7 +1297,7 @@ public final class WorldServer extends AWorldServer { BlockPos blockpos = entityplayermp.getPosition(); double d0 = blockpos.distanceSq(xCoord, yCoord, zCoord); - if(d0 <= 256.0D || longDistance && d0 <= 65536.0D) { + if(d0 <= 256.0D || particleType.isUnlimited() && d0 <= 65536.0D) { entityplayermp.connection.sendPacket(packet); } } @@ -1695,11 +1689,11 @@ public final class WorldServer extends AWorldServer { } for(EntityNPC player : this.players) { player.attackEntityFrom(DamageSource.causeExterminatusDamage(null), 5000); - Packet packet = new SPacketParticles(ParticleType.EXPLOSION_HUGE, true, + Packet packet = new SPacketParticles(ParticleType.EXPLOSION_HUGE, (float)player.posX, (float)this.getSeaLevel() + 4.0f, (float)player.posZ, (float)128.0, (float)2.0, (float)128.0, (float)0.15, 1000, 0); player.connection.sendPacket(packet); - packet = new SPacketParticles(ParticleType.EXPLOSION_NORMAL, true, + packet = new SPacketParticles(ParticleType.EXPLOSION_NORMAL, (float)player.posX, (float)this.getSeaLevel() + 4.0f, (float)player.posZ, (float)128.0, (float)2.0, (float)128.0, (float)0.15, 1000, 0); player.connection.sendPacket(packet);