From a9558b29481e374bedd464221e58e56211e78a18 Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Sat, 16 Nov 2013 20:47:48 -0500 Subject: [PATCH] Added pixie trail particles that keep crashing --- common/biomesoplenty/ClientProxy.java | 5 + .../biomesoplenty/blocks/BlockBOPLeaves.java | 5 +- .../biomesoplenty/entities/EntityPixie.java | 15 ++ .../particles/EntityMagicTreeFX.java | 2 +- .../particles/EntityPixieTrailFX.java | 140 ++++++++++++++++++ .../textures/particles/magictree.png | Bin 1457 -> 894 bytes .../textures/particles/pixietrail.png | Bin 0 -> 756 bytes 7 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 common/biomesoplenty/particles/EntityPixieTrailFX.java create mode 100644 resources/assets/biomesoplenty/textures/particles/pixietrail.png diff --git a/common/biomesoplenty/ClientProxy.java b/common/biomesoplenty/ClientProxy.java index 3ae1b1737..921f48e90 100644 --- a/common/biomesoplenty/ClientProxy.java +++ b/common/biomesoplenty/ClientProxy.java @@ -37,6 +37,7 @@ import biomesoplenty.entities.render.RenderRosester; import biomesoplenty.entities.render.RenderWasp; import biomesoplenty.particles.EntityDandelionFX; import biomesoplenty.particles.EntityMagicTreeFX; +import biomesoplenty.particles.EntityPixieTrailFX; import biomesoplenty.particles.EntitySteamFX; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -132,6 +133,10 @@ public class ClientProxy extends CommonProxy { { entityfx = new EntityMagicTreeFX(mc.theWorld, x, y, z, MathHelper.getRandomDoubleInRange(rand, -0.03, 0.03), -0.02D, MathHelper.getRandomDoubleInRange(rand, -0.03, 0.03)); } + else if (string == "pixietrail") + { + entityfx = new EntityPixieTrailFX(mc.theWorld, x, y, z, MathHelper.getRandomDoubleInRange(rand, -0.03, 0.03), -0.02D, MathHelper.getRandomDoubleInRange(rand, -0.03, 0.03)); + } mc.effectRenderer.addEffect(entityfx); } diff --git a/common/biomesoplenty/blocks/BlockBOPLeaves.java b/common/biomesoplenty/blocks/BlockBOPLeaves.java index 606122aa4..5d727c512 100644 --- a/common/biomesoplenty/blocks/BlockBOPLeaves.java +++ b/common/biomesoplenty/blocks/BlockBOPLeaves.java @@ -149,7 +149,10 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable { if (!(world.getBlockId(x, y - 1, z) == Blocks.leaves1.get().blockID && world.getBlockMetadata(x, y - 1, z) == 2)) { - BiomesOPlenty.proxy.spawnParticle("magictree", x + random.nextFloat(), y + 0.9F, z + random.nextFloat()); + if (random.nextInt(5) == 0) + { + BiomesOPlenty.proxy.spawnParticle("magictree", x + random.nextFloat(), y + 0.9F, z + random.nextFloat()); + } } } diff --git a/common/biomesoplenty/entities/EntityPixie.java b/common/biomesoplenty/entities/EntityPixie.java index ee76a1428..bb317d48c 100644 --- a/common/biomesoplenty/entities/EntityPixie.java +++ b/common/biomesoplenty/entities/EntityPixie.java @@ -1,5 +1,6 @@ package biomesoplenty.entities; +import biomesoplenty.BiomesOPlenty; import biomesoplenty.api.Items; import net.minecraft.block.material.Material; import net.minecraft.item.Item; @@ -88,6 +89,20 @@ public class EntityPixie extends EntityFlyingMob this.entityDropItem(new ItemStack(Items.miscItems.get(), 1, 11), 0.0F); } } + + @Override + public void onEntityUpdate() + { + super.onEntityUpdate(); + + for (int i = 0; i < 3; i++) + { + if (this.rand.nextInt(3) == 0) + { + BiomesOPlenty.proxy.spawnParticle("pixietrail", this.posX + (this.rand.nextDouble()) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - (double)this.yOffset, this.posZ + (this.rand.nextDouble()) * (double)this.width); + } + } + } @Override protected String getLivingSound() diff --git a/common/biomesoplenty/particles/EntityMagicTreeFX.java b/common/biomesoplenty/particles/EntityMagicTreeFX.java index 10f17addc..03d78a866 100644 --- a/common/biomesoplenty/particles/EntityMagicTreeFX.java +++ b/common/biomesoplenty/particles/EntityMagicTreeFX.java @@ -87,7 +87,7 @@ public class EntityMagicTreeFX extends EntityFX float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); tessellator.startDrawingQuads(); - tessellator.setBrightness(75); + tessellator.setBrightness(150); tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1.0F); tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9); diff --git a/common/biomesoplenty/particles/EntityPixieTrailFX.java b/common/biomesoplenty/particles/EntityPixieTrailFX.java new file mode 100644 index 000000000..d69a8e525 --- /dev/null +++ b/common/biomesoplenty/particles/EntityPixieTrailFX.java @@ -0,0 +1,140 @@ +package biomesoplenty.particles; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Direction; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +public class EntityPixieTrailFX extends EntityFX +{ + private static final String texture = "biomesoplenty:textures/particles/pixietrail.png"; + + float pixieTrailParticleScale; + + public EntityPixieTrailFX(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 EntityPixieTrailFX(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.particleScale *= 0.75F; + this.particleScale *= par14; + this.pixieTrailParticleScale = this.particleScale; + this.particleMaxAge = (int)((8.0D / (Math.random() * 0.8D + 0.2D)) * 8); + this.particleMaxAge = (int)((float)this.particleMaxAge * par14); + this.particleAge = (particleMaxAge / 2) + (int)((particleMaxAge / 2) * par1World.rand.nextInt(7)); + 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(GL11.GL_BLEND); + 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); + + tessellator.startDrawingQuads(); + tessellator.setBrightness(175); + + tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1.0F); + 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(GL11.GL_BLEND); + GL11.glDepthMask(true); + + GL11.glPopMatrix(); + + FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation("textures/particle/particles.png")); + tessellator.startDrawingQuads(); + } + + @Override + public void onUpdate() + { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (particleAge++ >= particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - particleAge * 8 / particleMaxAge); + 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 index debf65f753ed3bac2b8f2eb0cc4ca9982009bf12..80b5ab016184bba24971bd3ff880cbb772d0dae1 100644 GIT binary patch literal 894 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBufiR<}hF1enP^!c=q9iy!t)x7$D3u`~F*C13&(AePq0Cs% zRL{`R{j-xf0|V1rPZ!6KinzDeZunckJ5q$CkynGgp-K z9eT{nb?-0m46cgXvvG0e8=iHs{$c%2simK)uUKV9bcO#o z{B_F*u6_GU&0_TPzc^REx6pCtxccts=S}D5&;9-;x~7+7k&NLJ?{gWOqEr5DC|G5F z$7*%<@x$7N|4VbG*)3Jf^p9JAOnc`x^L=qquiM>h%CkNjs95h`fBim>Q|42ZGx^`0 zKL7slIy`E5;;yUQ#ex?e9XBz_Z+P=(@ywe&;R)Nt)8hK>AKJWf&HT2Ry@x-j#O>_W zo;~O6;|f#rU4ISs3g&;^_~*m=ljml3H*9{-IQ_jqd33tsOTM<_vjiRA9_(Bi^A3wMC@4pWfJ8csmhxN4|e{TK!{Aqzyd-ust-dq2w z3+Rmy+aLEoQucUZ-cOl3+3b(i7%G?=)JF;YVc>9`&z@06MDU98CYMvd?7`sa>gTe~ HDWM4fSOZoO 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)) diff --git a/resources/assets/biomesoplenty/textures/particles/pixietrail.png b/resources/assets/biomesoplenty/textures/particles/pixietrail.png new file mode 100644 index 0000000000000000000000000000000000000000..0e13c50fc36651d43e2939fa875d67f4a67635d0 GIT binary patch literal 756 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEa{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P^!c=q9iy!t)x7$D3u`~F*C13&(AePq0Cs%RL{`R{j-xf0|Qfm zr;B4qMcmtK8+|_qh&UulwIy&)Tad<(rM6&6GSjLJOhT;E7YrG6g%@~aDlPS%*!_O< ze1nh5(}I>fn4>NGcOvsY!SB_4=}T_zeVbJA^3V0o_8B^s@9Nhbjdigpwe{P7&hlc8 zo!Qy=x>&C}Tc!)2|NHgr@3K#IcfNV+o|e_!eR}O=hEH-oP1g#?FqFJMo*mwF;`-wGJLmn`@n*gJul*Y)_n&x}TKsI< zjQN|_KD~1CsLU^&bC+*g9eld)>y-C@d3JuddVN*>`=qM>T&o#Q^*229d^D%x6z7{$ zsl3zcd?SnWRx)2`3cGi@y5#>hfvLjr{{J`Kegy%o;m%qtAsh@0bvH4QG!4i>~gJP=3^;L U^