Posted July 1, 201510 yr Hello, here i will present you 2 weird bugs with particles! (While describing, i'll present you responsible code parts. Links to full classes are on the bottom of the page...) 1) Wierd velocity... Using my code, particles should go in random vector around my look, but they do this instead: Herу main spawning code: @Override public void createParticles(EntityLivingBase entity, boolean b){ if(b){ if(vectoredAffect(entity)){ World world = entity.worldObj; PositionnedRotatedRangedVec3 vvec = new PositionnedRotatedRangedVec3(entity.worldObj, entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch, getDegree(entity), getRange(entity)); Vec3[] vec2s = vvec.getMainVecs(); for(int i = 0; i < particleAmount(); i++){ Vec3 pvec = Vec3Utils.getRandomVecBetween(random, vec2s); if(createNameBasedParticles()){ world.spawnParticle(getParticleName(), entity.posX, entity.posY, entity.posZ, pvec.xCoord, pvec.yCoord, pvec.zCoord); } else { world.spawnEntityInWorld(new EntityFXBreathingParticles(world, entity.posX, entity.posY, entity.posZ, pvec.xCoord, pvec.yCoord, pvec.zCoord, getR(), getG(), getB(), getA())); } } } } } It becomes even stranger if i return false on createNameBasedParticles(), which spawns vanilla particles with same velocity values and this... works... Again, all concerned classes on the bottom of the page. 2) Really strange icon... I'm trying to set particle icon in constructor, to render it with: public EntityFXBreathingParticles(World world, double posX, double posY, double posZ, double velX, double velY, double velZ, float r, float g, float b, float a) { super(world, posX, posY, posZ, velX, velY, velZ); setRBGColorF(r, g, b); setAlphaF(a); setParticleIcon(new IIcon() { @Override public float getMinV() { return 0; } @Override public float getMinU() { return 0; } @Override public float getMaxV() { return 8; } @Override public float getMaxU() { return 8; } @Override public float getInterpolatedV(double p_94207_1_) { return 0; } @Override public float getInterpolatedU(double p_94214_1_) { return 0; } @Override public int getIconWidth() { return 8; } @Override public String getIconName() { return BreathModBase.MODID + ":textures/paticles/breath.png"; } @Override public int getIconHeight() { return 8; } }); } This particle icon to be used is in specified location, but my texture is not rendered: I'm not getting any missing texture errors. It is not rendered incorrectly. It is not another flat icon. IT IS MINI BLOCKS OF SNOW!!!! No, seriously, where is a logic there? How can flat icon draw blocks of snow in 3D... Ok, here's all the code conserned. Spawn methods (and methods called from main): https://gist.github.com/elix-x/c4c4ac5799a17bf0e21a Particles class: https://gist.github.com/elix-x/e1da82ce1f5738362465 PositionnedRotatedRangedVec3.class: https://gist.github.com/elix-x/2795d7b845b11bc9d910 Vec3Utils.class: https://gist.github.com/elix-x/de0de6504fdad2d1849c SpecialArrayUtils.class: https://gist.github.com/elix-x/4058bf72841d6a9f0f30 AdvancedRandomUtils.class: https://gist.github.com/elix-x/228fa0c176650bd1d958 Hope that's all... Thanks for help! If you have any questions - just ask! Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
July 1, 201510 yr 1. Your motion vector doesn't get correctly applied to your FX, due to EntityFX's standard motion parameters. What you should do, and what the vanilla SmokeFX does (where it works correctly) is give the super constructor within your particles constructor a value of 0.0 on all three motion axes (X;Y;Z), then manually set the motionX/Y/Z fields within your constructor to the motion parameters. public Particle(world, x, y, z, velX, velY, velZ, r, g, b, a) { super(world, x, y, z, 0.0D, 0.0D, 0.0D); this.motionX = velX; this.motionY = velY; this.motionZ = velZ; } 2. Your IIcon instance does absolutely nothing. Sadly there's no standard implementation of IIcon for particles, so I wrote my own: https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/IconParticle.java Feel free to use it. And here's an example on how to use it: https://github.com/SanAndreasP/TurretModRebirth/blob/master/java/de/sanandrew/mods/turretmod/client/particle/ParticleItemTransmitterAction.java#L20 (Please note that I don't bind my texture in renderParticle, since it is rendered in my own particle renderer, so you can ignore this detail) Another problem I see is you try to bind the texture in the renderParticle method, which breaks every particle in existance, since it is now bound to your texture. Re-binding back to the vanilla texture doesn't fix it, it just breaks your particles, because the renderer only uses the last bound texture. What you'd need to do is: draw the current Tessellator via tesselarator.draw() re-initialize the Tessellator drawing via tesselarator.stardDrawingQuads() bind your texture render your particle call tesselarator.draw() again to render your particle re-initialize the Tessellator drawing again via tesselarator.stardDrawingQuads() bind the vanilla texture Please consider this decreases performance and is a VERY HACKY solution, since you draw each particle of yours in a seperate drawing cycle and effectively splitting the default one. This was the reason I made my own FX renderer. You can find the files for those here, if you're interested: https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/mod/client/particle/SAPEffectRenderer.java https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/mod/client/event/EventWorldRenderLast.java https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/EntityParticle.java EDIT: world.spawnEntityInWorld will render your particles as cubes, since it spawns them as entities (hence the name) and not as particles. The RenderManager doesn't have any rendering info for particles. The correct method to spawn custom particles is Minecraft.getMinecraft.effectRenderer.addEffect(customParticleInstance) Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
July 1, 201510 yr Author 1. Your motion vector doesn't get correctly applied to your FX, due to EntityFX's standard motion parameters. What you should do, and what the vanilla SmokeFX does (where it works correctly) is give the super constructor within your particles constructor a value of 0.0 on all three motion axes (X;Y;Z), then manually set the motionX/Y/Z fields within your constructor to the motion parameters. public Particle(world, x, y, z, velX, velY, velZ, r, g, b, a) { super(world, x, y, z, 0.0D, 0.0D, 0.0D); this.motionX = velX; this.motionY = velY; this.motionZ = velZ; } 2. Your IIcon instance does absolutely nothing. Sadly there's no standard implementation of IIcon for particles, so I wrote my own: https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/IconParticle.java Feel free to use it. And here's an example on how to use it: https://github.com/SanAndreasP/TurretModRebirth/blob/master/java/de/sanandrew/mods/turretmod/client/particle/ParticleItemTransmitterAction.java#L20 (Please note that I don't bind my texture in renderParticle, since it is rendered in my own particle renderer, so you can ignore this detail) Another problem I see is you try to bind the texture in the renderParticle method, which breaks every particle in existance, since it is now bound to your texture. Re-binding back to the vanilla texture doesn't fix it, it just breaks your particles, because the renderer only uses the last bound texture. What you'd need to do is: draw the current Tessellator via tesselarator.draw() re-initialize the Tessellator drawing via tesselarator.stardDrawingQuads() bind your texture render your particle call tesselarator.draw() again to render your particle re-initialize the Tessellator drawing again via tesselarator.stardDrawingQuads() bind the vanilla texture Please consider this decreases performance and is a VERY HACKY solution, since you draw each particle of yours in a seperate drawing cycle and effectively splitting the default one. This was the reason I made my own FX renderer. You can find the files for those here, if you're interested: https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/mod/client/particle/SAPEffectRenderer.java https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/mod/client/event/EventWorldRenderLast.java https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/EntityParticle.java EDIT: world.spawnEntityInWorld will render your particles as cubes, since it spawns them as entities (hence the name) and not as particles. The RenderManager doesn't have any rendering info for particles. The correct method to spawn custom particles is Minecraft.getMinecraft.effectRenderer.addEffect(customParticleInstance) So you mean that to render with custom exture, i have to go with custom rendering? Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
July 1, 201510 yr So you mean that to render with custom exture, i have to go with custom rendering? To be short, yes. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
July 1, 201510 yr Author So you mean that to render with custom exture, i have to go with custom rendering? To be short, yes. I don't think i need it... After trying this and getting awesome result: @Override public void renderParticle(Tessellator tesselator, float f1, float f2, float f3, float f4, float f5, float f6) { Minecraft.getMinecraft().getTextureManager().bindTexture(texture); renderParticleSpecial(tesselator, f1, f2, f3, f4, f5, f6); Minecraft.getMinecraft().getTextureManager().bindTexture(particleTextures); } public void renderParticleSpecial(Tessellator tesselator, float ff1, float ff2, float ff3, float ff4, float ff5, float ff6) { float f10 = 0.1F * this.particleScale; float f6 = 0; float f7 = 8; float f8 = 0; float f9 = 8; float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)ff1 - interpPosX); float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)ff1 - interpPosY); float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)ff1 - interpPosZ); tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); tesselator.addVertexWithUV((double)(f11 - ff2 * f10 - ff5 * f10), (double)(f12 - ff3 * f10), (double)(f13 - ff4 * f10 - ff6 * f10), (double)f7, (double)f9); tesselator.addVertexWithUV((double)(f11 - ff2 * f10 + ff5 * f10), (double)(f12 + ff3 * f10), (double)(f13 - ff4 * f10 + ff6 * f10), (double)f7, (double)f8); tesselator.addVertexWithUV((double)(f11 + ff2 * f10 + ff5 * f10), (double)(f12 + ff3 * f10), (double)(f13 + ff4 * f10 + ff6 * f10), (double)f6, (double)f8); tesselator.addVertexWithUV((double)(f11 + ff2 * f10 - ff5 * f10), (double)(f12 - ff3 * f10), (double)(f13 + ff4 * f10 - ff6 * f10), (double)f6, (double)f9); } I think that now all problems are solved!!! Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.