From 5f3eedd795469b1ece6ebd5be3b2ffbe53f8f15f Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Sat, 16 Nov 2013 17:13:40 -0500 Subject: [PATCH] Tried to add particles for magic leaves --- common/biomesoplenty/ClientProxy.java | 5 + .../biomesoplenty/blocks/BlockBOPLeaves.java | 5 + .../particles/EntityMagicTreeFX.java | 141 ++++++++++++++++++ .../textures/particles/magictree.png | Bin 0 -> 1457 bytes 4 files changed, 151 insertions(+) create mode 100644 common/biomesoplenty/particles/EntityMagicTreeFX.java create mode 100644 resources/assets/biomesoplenty/textures/particles/magictree.png diff --git a/common/biomesoplenty/ClientProxy.java b/common/biomesoplenty/ClientProxy.java index 62a460f69..70b4e6cf0 100644 --- a/common/biomesoplenty/ClientProxy.java +++ b/common/biomesoplenty/ClientProxy.java @@ -33,6 +33,7 @@ import biomesoplenty.entities.render.RenderPixie; import biomesoplenty.entities.render.RenderRosester; import biomesoplenty.entities.render.RenderWasp; import biomesoplenty.particles.EntityDandelionFX; +import biomesoplenty.particles.EntityMagicTreeFX; import biomesoplenty.particles.EntitySteamFX; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -122,6 +123,10 @@ public class ClientProxy extends CommonProxy { { entityfx = new EntitySteamFX(mc.theWorld, x, y, z, 0.0D, 0.0D, 0.0D); } + else if (string == "magictree") + { + entityfx = new EntityMagicTreeFX(mc.theWorld, x, y, z, 0.0D, 0.0D, 0.0D); + } mc.effectRenderer.addEffect(entityfx); } diff --git a/common/biomesoplenty/blocks/BlockBOPLeaves.java b/common/biomesoplenty/blocks/BlockBOPLeaves.java index 129bb09d1..59420b6aa 100644 --- a/common/biomesoplenty/blocks/BlockBOPLeaves.java +++ b/common/biomesoplenty/blocks/BlockBOPLeaves.java @@ -144,6 +144,11 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable double d2 = z + random.nextFloat(); world.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D); } + + if (world.getBlockId(x, y, z) == Blocks.leaves1.get().blockID && world.getBlockMetadata(x, y, z) == 2) + { + BiomesOPlenty.proxy.spawnParticle("magictree", x + random.nextFloat(), y - 16.0F, z + random.nextFloat()); + } super.randomDisplayTick(world, x, y, z, random); diff --git a/common/biomesoplenty/particles/EntityMagicTreeFX.java b/common/biomesoplenty/particles/EntityMagicTreeFX.java new file mode 100644 index 000000000..5398c01a0 --- /dev/null +++ b/common/biomesoplenty/particles/EntityMagicTreeFX.java @@ -0,0 +1,141 @@ +package biomesoplenty.particles; + +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +public class EntityMagicTreeFX extends EntityFX +{ + private static final String texture = "biomesoplenty:textures/particles/magictree.png"; + + float magicTreeParticleScale; + + public EntityMagicTreeFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + this(par1World, par2, par4, par6, par8, par10, par12, 1.0F); + } + + public EntityMagicTreeFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + this.particleRed = this.particleGreen = this.particleBlue = (float)(Math.random() * 0.30000001192092896D); + this.particleScale *= 0.75F; + this.particleScale *= par14; + this.magicTreeParticleScale = this.particleScale; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * par14); + this.noClip = false; + } + + @Override + public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f = (particleAge + par2) / particleMaxAge * 32.0F; + + if (f < 0.0F) + { + f = 0.0F; + } + + if (f > 1.0F) + { + f = 1.0F; + } + + particleScale = particleScale * f; + + tessellator.draw(); + GL11.glPushMatrix(); + + GL11.glDepthMask(false); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 1); + + FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(texture)); + + float f6 = (float)this.particleTextureIndexX / 16.0F; + float f7 = f6 + 0.0624375F; + float f8 = (float)this.particleTextureIndexY / 16.0F; + float f9 = f8 + 0.0624375F; + float f10 = 0.1F * this.particleScale; + + if (this.particleIcon != null) + { + f6 = this.particleIcon.getMinU(); + f7 = this.particleIcon.getMaxU(); + f8 = this.particleIcon.getMinV(); + f9 = this.particleIcon.getMaxV(); + } + + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); + float f14 = 1.0F; + + tessellator.startDrawingQuads(); + tessellator.setBrightness(10); + + tessellator.setColorRGBA_F(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha); + tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9); + tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8); + tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f6, (double)f8); + tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f6, (double)f9); + + tessellator.draw(); + + GL11.glDisable(3042); + GL11.glDepthMask(true); + + GL11.glPopMatrix(); + + FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation("textures/particle/particles.png")); + tessellator.startDrawingQuads(); + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() + { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (particleAge++ >= particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - particleAge * 8 / particleMaxAge); + motionY -= 0.0004D; + this.moveEntity(motionX, motionY, motionZ); + + if (posY == prevPosY) + { + motionX *= 1.1D; + motionZ *= 1.1D; + } + + motionX *= 0.9599999785423279D; + motionY *= 0.9599999785423279D; + motionZ *= 0.9599999785423279D; + + if (onGround) + { + motionX *= 0.699999988079071D; + motionZ *= 0.699999988079071D; + } + } +} diff --git a/resources/assets/biomesoplenty/textures/particles/magictree.png b/resources/assets/biomesoplenty/textures/particles/magictree.png new file mode 100644 index 0000000000000000000000000000000000000000..debf65f753ed3bac2b8f2eb0cc4ca9982009bf12 GIT binary patch literal 1457 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H3?#oinD~={ftew|C&U%VmD~D5bKMv9EkD)w ze^lQ6TXD~SwcUR-xBk@H`A2)#Kh1rA^>+W#-}^&v|1Z70{|z>NGurjVXwMhpUH^>s z{xskBU;gk%wFCdv5C2y^`djbt7wv;TwGaH&KKe)V_x+o{bzLMzwx=h2Iu~pp8jWg`oGzk{}zY;TOa*zaqPe4x&Jn2{@b4WZ+PLq z@suf(E{-7;ac?i33_9c>(2!VO7%ozN)b!o%W4s{> z@471gPtRO#UHl>8>4A`w2lw-THl7^v(eaYvTL1a^7q+mhcoih^9%UXX_ik^NqNf{g;{@^PFMT4T zZ?4=`zv#QgK56^wwHN+yY5dIl!FQudm;0Ju}-+!Z#@G1U~{fuwSm(2Jn f&NcsKCoH=k%yVqZs^ZQ!Ak#cu{an^LB{Ts5F2y)) literal 0 HcmV?d00001