Posted September 2, 201312 yr Hi everyone, i'm porting my vanilla mod to forge, and i'm having a problem... With Vanilla, i register a new ParticleFX in the "RenderGlobal" class and i use the method: String particle = "myParticle"; this.worldObj.spawnParticle(particle, this.posX, this.posY, this.posZ,a,-b,c); Everything works fine. With forge, i use this way (without modifying RenderGlobal.java then): EntityFX particle = new EntitySpellFXDamage(w, player.posX, player.posY, player.posZ,a,-b,c); FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle); With forge, my game crash when i spawn this particles and i have a NullPointer error on : moveEntity(motionX, motionY, motionZ); (inside my EntitySpellFXDamage class) Here's my class: package MagicCrusade.particles; import java.util.List; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; public class EntitySpellFXDamage extends EntityFX { float smokeParticleScale; public EntitySpellFXDamage(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 EntitySpellFXDamage(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); motionX *= 0.10000000149011612D; motionY *= 0.10000000149011612D; motionZ *= 0.10000000149011612D; motionX += par8; motionY += par10; motionZ += par12; particleRed = particleGreen = particleBlue = /*(float)(Math.random() * 0.30000001192092896D)*/0; particleRed = 255; particleGreen = (float)Math.random(); particleScale *= 0.75F; particleScale *= par14; smokeParticleScale = particleScale; particleMaxAge = (int)(8D / (Math.random() * 0.80000000000000004D + 0.20000000000000001D)); particleMaxAge *= par14; noClip = false; } public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { float f = (((float)particleAge + par2) / (float)particleMaxAge) * 32F; if (f < 0.0F) { f = 0.0F; } if (f > 1.0F) { f = 1.0F; } particleScale = smokeParticleScale * f; super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); } /** * Called to update the entity's position/logic. */ public void onUpdate() { prevPosX = posX; prevPosY = posY; prevPosZ = posZ; if (particleAge++ >= particleMaxAge) { setDead(); } setParticleTextureIndex(7 - (particleAge * / particleMaxAge); //motionY += 0.0040000000000000001D; moveEntity(motionX, motionY, motionZ); if (posY == prevPosY) { motionX *= 1.1000000000000001D; motionZ *= 1.1000000000000001D; } motionX *= 0.95999997854232788D; motionY *= 0.95999997854232788D; motionZ *= 0.95999997854232788D; if (onGround) { motionX *= 0.69999998807907104D; motionZ *= 0.69999998807907104D; } List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(0.25D, 1.0D, 0.25D)); if (list != null) { for (int i = 0; i < list.size(); i++) { Entity entity = (Entity)list.get(i); if (!entity.isDead) { if(entity instanceof EntityLivingBase && !(entity instanceof EntityPlayer)) { entity.setFire(4); this.setDead(); } } } } } } Thank for help! Maybe i have to register particles somewhere on thing like this... ?
September 2, 201312 yr EntityFX particle = new EntitySpellFXDamage(w, player.posX, player.posY, player.posZ,a,-b,c); FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle); Where did you put this ?
September 2, 201312 yr Author I put this after an algorythm to make an effect. Well, i remade my EntityFX and it seems to work now... It may come from the variable World, sorry!
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.