From c8a70d6a082ab2db8374831417cff4aa1505521e Mon Sep 17 00:00:00 2001 From: Adubbz Date: Mon, 13 May 2013 17:49:06 +1000 Subject: [PATCH] Attempted to get particles working. Used the dart blower as the test --- src/minecraft/biomesoplenty/ClientProxy.java | 8 ++ src/minecraft/biomesoplenty/CommonProxy.java | 5 + .../items/projectiles/EntityDart.java | 2 +- .../particles/EntityDandelionFX.java | 106 ++++++++++++++++++ .../textures/particles/dandelion.png | Bin 0 -> 200 bytes 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/minecraft/biomesoplenty/particles/EntityDandelionFX.java create mode 100644 src/minecraft/mods/BiomesOPlenty/textures/particles/dandelion.png diff --git a/src/minecraft/biomesoplenty/ClientProxy.java b/src/minecraft/biomesoplenty/ClientProxy.java index 1638baa1b..4cb8a7457 100644 --- a/src/minecraft/biomesoplenty/ClientProxy.java +++ b/src/minecraft/biomesoplenty/ClientProxy.java @@ -12,6 +12,7 @@ import biomesoplenty.items.projectiles.EntityDart; import biomesoplenty.items.projectiles.EntityMudball; import biomesoplenty.items.projectiles.EntityPoisonDart; import biomesoplenty.items.projectiles.RenderDart; +import biomesoplenty.particles.EntityDandelionFX; import cpw.mods.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { @@ -46,6 +47,13 @@ public class ClientProxy extends CommonProxy { entityfx = new EntityBreakingFX(mc.theWorld, x, y, z, Items.dart.get(), mc.renderEngine); mc.effectRenderer.addEffect(entityfx); } + + @Override + public void spawnDandelion(World world, double x, double y, double z, double xVel, double yVel, double zVel) + { + EntityDandelionFX entityfx = new EntityDandelionFX(mc.theWorld, x, y, z, 1.0F); + mc.effectRenderer.addEffect(entityfx); + } @Override public int addArmor(String armor) diff --git a/src/minecraft/biomesoplenty/CommonProxy.java b/src/minecraft/biomesoplenty/CommonProxy.java index 9c17286a9..a1383efca 100644 --- a/src/minecraft/biomesoplenty/CommonProxy.java +++ b/src/minecraft/biomesoplenty/CommonProxy.java @@ -27,4 +27,9 @@ public class CommonProxy { { } + + public void spawnDandelion(World world, double x, double y, double z, double xVel, double yVel, double zVel) + { + + } } \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java b/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java index 96d0c0f1d..deea07505 100644 --- a/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java +++ b/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java @@ -231,7 +231,7 @@ public class EntityDart extends EntityArrow for (int p = 0; i < 16; ++i) { - BiomesOPlenty.proxy.spawnDart(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + BiomesOPlenty.proxy.spawnDandelion(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); diff --git a/src/minecraft/biomesoplenty/particles/EntityDandelionFX.java b/src/minecraft/biomesoplenty/particles/EntityDandelionFX.java new file mode 100644 index 000000000..d1bbf1267 --- /dev/null +++ b/src/minecraft/biomesoplenty/particles/EntityDandelionFX.java @@ -0,0 +1,106 @@ +package biomesoplenty.particles; + +import cpw.mods.fml.client.FMLClientHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.RenderEngine; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Icon; +import net.minecraft.world.World; + +public class EntityDandelionFX extends EntityFX { + + float reddustParticleScale; + + public EntityDandelionFX(World par1World, double par2, double par4, double par6, float par8) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + + float f4 = (float)Math.random() * 0.4F + 0.6F; + this.particleScale *= 0.75F; + this.particleScale *= par8; + this.reddustParticleScale = this.particleScale; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * par8); + this.noClip = false; + + this.particleTextureIndexX = 0; + this.particleTextureIndexY = 0; + } + + @Override + public int getFXLayer() + { + return 1; + } + + @Override + public void setParticleTextureIndex(int par1) + { + } + + @Override + public void setParticleIcon(RenderEngine par1RenderEngine, Icon par2Icon) + { + final String[] textures = new String[] {"/mods/BiomesOPlenty/textures/particles/dandelion.png"}; + + Icon[] icon = new Icon[textures.length]; + par2Icon = icon[0]; + //Icon = par1RenderEngine.bindTexture("/mods/BiomesOPlenty/textures/particles/dandelion.png"); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.reddustParticleScale * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.posY == this.prevPosY) + { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} diff --git a/src/minecraft/mods/BiomesOPlenty/textures/particles/dandelion.png b/src/minecraft/mods/BiomesOPlenty/textures/particles/dandelion.png new file mode 100644 index 0000000000000000000000000000000000000000..ad3a35abcaf4380ab856e65bf323c9ee834e77e1 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvU_sT^vI+f@`}D@-i53Fx{=!R7(_FrQdC6r^m8mLdm8+`!J6*87D(k nYsQok{WT)Nn~IZVrH?Xy@;vZyZ(30R&