Posted January 23, 201510 yr I have an entity that spawns a ring of particles around it when it is summoned. I see the particles spawn but then minecraft crashes shortly after. Im not sure how to fix it since I knoe that I need to spawn my particle server side so that players can see it but I need my spawn method to be client side only. Here are my two culprit methods I believe @Override public void onUpdate() { super.onUpdate(); motionY += 0.01D; if (!worldObj.isRemote) { attackNearbyEntities(); if (ticksExisted > 0 && ticksExisted <= 40){ spawnParticleRing(); // crashes minecraft shortly after you see the particles spawn } if (ticksExisted > 40) { setDead(); releaseDrops(); } else if (ticksExisted % AttackTypeRanged.AIR.getSoundFrequency() == (AttackTypeRanged.AIR.getSoundFrequency() - 1)) { worldObj.playSoundAtEntity(this, AttackTypeRanged.AIR.getMovingSound(), AttackTypeRanged.AIR.getSoundPitch(rand), AttackTypeRanged.AIR.getSoundVolume(rand)); } } } This is how I spawn the particle ring and update it /** Updates the particle rings swirling angles and spawns a new ring of particles. */ @SideOnly(Side.CLIENT) private void spawnParticleRing() { yaw += yawVelocity; if (yaw > 2*Math.PI) yaw -= 2*Math.PI; if (Math.random() < 0.1) { pitchVelocity = 0.2f; } pitch += pitchVelocity; if (pitch > maxPitch) pitch = maxPitch; if (pitchVelocity > 0) { pitchVelocity -= 0.05f; } else { pitchVelocity = 0; } if (pitch > 0) { pitch -= 0.07f; } else { pitch = 0; } EffectRenderer effectRenderer = Minecraft.getMinecraft().effectRenderer; VisualEffectTornado ring = new VisualEffectTornado(worldObj, posX, posY + 0.1D, posZ, motionX, motionY, motionZ, yaw, pitch, 0.7f, effectRenderer); effectRenderer.addEffect(ring); ring.setDead(); // I suspect I have to destroy the ring somehow but im stuck as to how to do it } the errors in consol net.minecraft.util.ReportedException: Ticking entity at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:709) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.NullPointerException at net.minecraft.entity.Entity.moveEntity(Entity.java:709) ~[Entity.class:?] at net.minecraft.entity.EntityLivingBase.moveEntityWithHeading(EntityLivingBase.java:1678) ~[EntityLivingBase.class:?] at net.minecraft.entity.passive.EntityHorse.moveEntityWithHeading(EntityHorse.java:1340) ~[EntityHorse.class:?] at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2021) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:431) ~[EntityLiving.class:?] at net.minecraft.entity.EntityAgeable.onLivingUpdate(EntityAgeable.java:138) ~[EntityAgeable.class:?] at net.minecraft.entity.passive.EntityAnimal.onLivingUpdate(EntityAnimal.java:56) ~[EntityAnimal.class:?] at net.minecraft.entity.passive.EntityHorse.onLivingUpdate(EntityHorse.java:1035) ~[EntityHorse.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1814) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250) ~[EntityLiving.class:?] at net.minecraft.entity.passive.EntityHorse.onUpdate(EntityHorse.java:1073) ~[EntityHorse.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:2258) ~[World.class:?] at net.minecraft.world.World.updateEntities(World.java:2108) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) ~[MinecraftServer.class:?] ... 4 more [17:12:10] [server thread/ERROR]: This crash report has been saved to: C:\Users\{User\Desktop\modding\CustomMod_1.7.10\eclipse\.\crash-reports\crash-2015-01-22_17.12.10-server.txt [17:12:10] [server thread/INFO]: Stopping server [17:12:10] [server thread/INFO]: Saving players [17:12:10] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ---- // Uh... Did I do that? Time: 1/22/15 5:12 PM Description: Ticking entity java.lang.NullPointerException: Ticking entity at net.minecraft.entity.Entity.moveEntity(Entity.java:709) at net.minecraft.entity.EntityLivingBase.moveEntityWithHeading(EntityLivingBase.java:1678) at net.minecraft.entity.passive.EntityHorse.moveEntityWithHeading(EntityHorse.java:1340) at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2021) at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:431) at net.minecraft.entity.EntityAgeable.onLivingUpdate(EntityAgeable.java:138) at net.minecraft.entity.passive.EntityAnimal.onLivingUpdate(EntityAnimal.java:56) at net.minecraft.entity.passive.EntityHorse.onLivingUpdate(EntityHorse.java:1035) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1814) at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250) at net.minecraft.entity.passive.EntityHorse.onUpdate(EntityHorse.java:1073) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) at net.minecraft.world.World.updateEntity(World.java:2258) at net.minecraft.world.World.updateEntities(World.java:2108) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
January 23, 201510 yr Author When I call them on the client they do not spawn for some reason @Override public void onUpdate() { super.onUpdate(); motionY += 0.01D; if (!worldObj.isRemote) { attackNearbyEntities(); if (ticksExisted > 40) { setDead(); releaseDrops(); } else if (ticksExisted % AttackTypeRanged.AIR.getSoundFrequency() == (AttackTypeRanged.AIR.getSoundFrequency() - 1)) { worldObj.playSoundAtEntity(this, AttackTypeRanged.AIR.getMovingSound(), AttackTypeRanged.AIR.getSoundPitch(rand), AttackTypeRanged.AIR.getSoundVolume(rand)); } } else { spawnParticleRing(); // doesnt spawn atm } } if i put a System.out.println(); above spawnParticleRing() inside that else statement nothing gets printed. Furthermore if I replace the else statement with if(worldObj.isRemote){spawnParticleRing();} and put a System.out.println(); inside that if statement it still doesnt get called.
January 23, 201510 yr Author Also, as a note the on Update method overrides the onUpdate method in EntityThrowable
January 23, 201510 yr Author I am truly stumped by why the ,method is not being called when I provide an if(worldObj.isRemote) check arent showing up. Any ideas are appreciated
January 23, 201510 yr Author it was a registering issue, now solved Thanks everyone! and yes it works now
January 25, 201510 yr Just a little tip, you should move the spawning code out of your entity and into your Common Proxy and Client Proxy. CommonProxy: public void spawnParticleRing(){} ClientProxy: public void spawnParticleRing() { yaw += yawVelocity; if (yaw > 2*Math.PI) yaw -= 2*Math.PI; if (Math.random() < 0.1) { pitchVelocity = 0.2f; } pitch += pitchVelocity; if (pitch > maxPitch) pitch = maxPitch; if (pitchVelocity > 0) { pitchVelocity -= 0.05f; } else { pitchVelocity = 0; } if (pitch > 0) { pitch -= 0.07f; } else { pitch = 0; } EffectRenderer effectRenderer = Minecraft.getMinecraft().effectRenderer; VisualEffectTornado ring = new VisualEffectTornado(worldObj, posX, posY + 0.1D, posZ, motionX, motionY, motionZ, yaw, pitch, 0.7f, effectRenderer); effectRenderer.addEffect(ring); ring.setDead(); // I suspect I have to destroy the ring somehow but im stuck as to how to do it } In onUpdate(): public void onUpdate() { super.onUpdate(); motionY += 0.01D; YourMod.proxy.spawnParticleRing(); if (!worldObj.isRemote) { attackNearbyEntities(); if (ticksExisted > 40) { setDead(); releaseDrops(); } else if (ticksExisted % AttackTypeRanged.AIR.getSoundFrequency() == (AttackTypeRanged.AIR.getSoundFrequency() - 1)) { worldObj.playSoundAtEntity(this, AttackTypeRanged.AIR.getMovingSound(), AttackTypeRanged.AIR.getSoundPitch(rand), AttackTypeRanged.AIR.getSoundVolume(rand)); } } } Romejanic Creator of Witch Hats, Explosive Chickens and Battlefield!
February 19, 201510 yr Thanks Romejanic & diesieben07. I was racking my brain trying to figure out why it was still calling the client side, even with multiple client-side only checks in both classes. Putting it in the proxy did the trick + checking to see if worldObj.isRemote == true.
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.