Jump to content

[NVM][SOLVED IT][1.7.2]Custom EntityFX crash on item use


Recommended Posts


I have a question regarding spawning custom particles (EntityFX) on item press.

I created an EntityFX class, and it works just fine. F.e., when I use it in randomDisplayTick in a block, it looks as supposed, etc.

However, what I want to use it for is spawning particles above any block that was clicked with an item that I created. This is where the game crashes. Not instantly, though, but when i keep RMB pressed on the ground for a few seconds while holding my item,  the particles keep spawning and disappearing, but sometimes the game crashes. I tried decreasing the spawn rate of these particles, making them spawn on every fourth onItemUse call, but it still crashes. Here is the full error log:



I just can't figure out why it is crashing, so any help would be appreciated.


Here is the EntityFX code:


Link to comment
Share on other sites

Alright, I fixed it. Leaving this thread here, so that anybody with a similar issue can refer to it.

I reread the error log again, carefully, and found out that what was causing the issue was this code:

this.motionX = rand.nextFloat() * 0.1F;
this.motionY = rand.nextFloat() * 0.1F;
this.motionZ = rand.nextFloat() * 0.1F;

this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;

if (this.particleAge++ >= this.particleMaxAge)

this.moveEntity(this.motionX, this.motionY, this.motionZ);

Particularly, the moveEntity method. You can see it on lines 134 and 135 in the error log:

java.lang.NullPointerException: Ticking entity
	at net.minecraft.entity.Entity.moveEntity(Entity.java:735)

Apparently, this method has some issues when it receives random doubles as arguments, and it sometimes crashes.


Fixed it even more, by doing this:

this.motionX = rand.nextDouble() * 0.1D;
this.motionY = rand.nextDouble() * 0.1D;
this.motionZ = rand.nextDouble() * 0.1D;

Looks like Java really does not like float to double conversion, and when I stopped using floats, it all stopped crashing. Never mix up your primitive types!

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.

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.


  • Create New...

Important Information

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