Jump to content

1.7.10 | Game Crashes after particles spawn in (Instant or after period of time)


ScottehBoeh

Recommended Posts

Having a few issues when spawning in a custom Particle Entity.

 

When particles spawn in, game crashes with an error like following:

Reported exception thrown!

net.minecraft.util.ReportedException: Ticking Particle

at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:102) ~[EffectRenderer.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2146) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_73]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_73]

at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_73]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

Caused by: java.lang.NullPointerException

at net.minecraft.entity.Entity.moveEntity(Entity.java:692) ~[Entity.class:?]

at net.minecraft.client.particle.EntityAuraFX.onUpdate(EntityAuraFX.java:37) ~[EntityAuraFX.class:?]

at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:79) ~[EffectRenderer.class:?]

... 12 more

[00:15:56] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----

// Hey, that tickles! Hehehe!

 

Event Handler to spawn in particles (Blood):

public class DamageHandler {

 

    @SubscribeEvent

    public void playerTick(LivingHurtEvent event) {

        if (event.entity instanceof EntityPlayer) {

            EntityPlayer theEntity = (EntityPlayer) event.entity;

            double motionX = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionY = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionZ = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            for (int i = 1; i < 4; i++) {

                EntityFX particleBlood = new EntityParticleBlood(theEntity.worldObj,

                        theEntity.posX + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        theEntity.posY + 0.5D + theEntity.worldObj.rand.nextFloat() * theEntity.height,

                        theEntity.posZ + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        motionX, motionY, motionZ);

                Minecraft.getMinecraft().effectRenderer.addEffect(particleBlood);

            }

        }

        if (event.entity instanceof EntityInfected) {

            EntityInfected theEntity = (EntityInfected) event.entity;

            double motionX = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionY = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionZ = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            for (int i = 1; i < 4; i++) {

                EntityFX particleInfectedBlood = new EntityParticleInfectedBlood(theEntity.worldObj,

                        theEntity.posX + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        theEntity.posY + 0.5D + theEntity.worldObj.rand.nextFloat() * theEntity.height,

                        theEntity.posZ + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        motionX, motionY, motionZ);

                Minecraft.getMinecraft().effectRenderer.addEffect(particleInfectedBlood);

            }

        }

    }

 

}

Actual Particle Entity:

public class EntityParticleInfectedBlood extends EntityAuraFX

{

    public EntityParticleInfectedBlood(World parWorld,

                                      double parX, double parY, double parZ,

                                      double parMotionX, double parMotionY, double parMotionZ)

    {

        super(parWorld, parX, parY, parZ, parMotionX, parMotionY, parMotionZ);

        setParticleTextureIndex(80); // same as happy villager

        particleScale = 2.0F;

        particleGravity = 5.5F;

        motionY = -0.2D;

        setRBGColorF(0x88, 0x00, 0x88);

        noClip = false;

    }

}

 

Event Handler is registered under preInit stage:

        if (event.getSide() == Side.CLIENT) {

            this.keyHandler = new InputHandler();

            FMLCommonHandler.instance().bus().register((Object)this.keyHandler);

            FMLCommonHandler.instance().bus().register(new DamageHandler());

            MinecraftForge.EVENT_BUS.register(new DamageHandler());

 

        }

 

If anyone knows how to fix this error, please let me know. Thanks :)

Link to comment
Share on other sites

Considering that you are working on project such as yours, one could expect that you know what you are doing - yet, you know nothing about not only internals but also the game design itself.

 

This had to be said, because "for my next trick" I will send you back to absolute ROOTS of modding! YAY! :)

Those roots are obviously - SIDES!

http://mcforge.readthedocs.io/en/latest/concepts/sides/

 

You are referring to @SideOnly stuff (Minecraft.class) from common code. If that was not bad enough - you are doing it from code that is fired ONLY on server (LivingHurtEvent). That all basically means you are accessing client thread from server thread (particles from hurt event) which is HERESY in modding world. In addition you are using stuff that was NEVER supposed to be used (event.getSide(), which can be effectively eliminated using @SidedProxy). There are also minor problems like wtf is that Object cast doing in key handler?

 

Like for reals man - If I were to explain where lies your problem I'd have to write whole damn essay on how to do things right.

 

 

 

That is why I am sending you to actually read good portion of docs and maybe other sources (google?).

After that - redesign your structures from ground up, apply @SidedProxy, make some experiments (like on which side and when event is fired - simple Syso can show you), check callbacks of events to know how they work. Idk... all kinds of stuff.

 

You don't dive in serious modding if you are not prepared! That will only cause that in few weeks you will have to rewrite everything you wrote.

 

Not to mention the fact that you are on 1.7.10... Jeeeeez - have fun updating after, when you finish your mod, it will turn out that noone is playing 1.7 anymore (1.7 code is so different that it will basically go to trashcan). Like for real - 1.8+ is million times better than previous (in structure... no wait - everything!).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.