Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Does anyone know of any tutorial or example code on creating particles and spawning them? I'm having a hard time figuring how to do it from the Javadocs code, and I'd like to use particles to tell the player that one of my blocks is working or has reached a certain state(especifically, that it's consuming some fuel to produce items).

 

Thanks in advance. :)

Maybe you can try examinig Vanilla texture fx. Change some things here and there and then see what the changes are ingame. Try to see what everything does and then you are maybe good to go.

  • Author

Well, as far as I figured from examining Vanilla code, I can only create particles available in the Vanilla build -- they are identified by String arguments and there's no way to access the EntityFX class -- and only via some functions -- so far, only in the displayRandomTick function of the Block. In other words, the whole thing is pretty limited as far as I can see.

 

I'd like to at least be able to play around with what I have, like, for example, flashing green redstone particles over a block.

 

I'm gonna try and use some raw spawnEntityInWorld to do that. Wish me luck.

I was messing with this the other day because I wanted a small candle flame for a block. I was able to create new particle effects and use them without too much trouble.

 

First I created a new class that extends EntityFX. See something like EntityFlameFX for example. To get my particle to spawn I used the displayRandomTick method on the block and used something similar to this:

 

EntityFX candleFlame = new EntityCandleFX(world, x, y, z, 0.0D, 0.0D, 0.0D);
Minecraft.getMinecraft().effectRenderer.addEffect(candleFlame)

 

My x, y, z values are setup with a switch case that depends on 1 of 4 angles that takes the x, y, z, sent to the randomDisplayTick method and adds those with my desired offsets for each angle.

 

Hopefully that is helpful. Good luck.  :D

  • Author

Very good, Nuchaz, that worked! :D I haven't created a new custom EntityFX class yet, but I managed to do some green dust flying from my block. Awesome!

 

But now I'm getting some weird problems... When I have my sparkles running(I put the code inside a Tile Entity, sparkling at random times about 8 times each 10 seconds) I randomly get... this

 

-- Head --
Stacktrace:
at net.minecraft.entity.Entity.moveEntity(Entity.java:769)
at net.minecraft.entity.EntityLiving.moveEntityWithHeading(EntityLiving.java:1535)
at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:1823)
at net.minecraft.entity.monster.EntityMob.onLivingUpdate(EntityMob.java:37)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:843)
at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:45)
at net.minecraft.entity.monster.EntityCreeper.onUpdate(EntityCreeper.java:173)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2295)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:645)
at net.minecraft.world.World.updateEntity(World.java:2257)

-- Entity being ticked --
Details:
Entity Type: Creeper (net.minecraft.entity.monster.EntityCreeper)
Entity ID: 178
Name: Creeper
Exact location: -89.98, 41.00, 5.49
Block location: World: (-90,41,5), Chunk: (at 6,2,5 in -6,0; contains blocks -96,0,0 to -81,255,15), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Momentum: 0.00, -0.08, 0.00
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:2103)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:514)

(...)
java.lang.NullPointerException

 

Actually, that's not even the only error I get, sometimes it's sheep, or chicken or... well, anything. It's pretty random. Any idea? Maybe this isn't a good way to go about with particles? :/

 

SUDDEN REALIZATION EDIT: Wait, I should be doing this on Client side only, isn't it?

  • Author

Well, tried adding a check for Client Side before adding any particles, but the error is still happening. :| Any ideas?

  • Author

Okay, quick update: doing this in randomDisplayTick() works fine. Using addEffect instead of spawnParticle is that I can instantiate the entity and change it before to, say,  make it green instead of the usual red.

 

Now I have other problems to deal with but this is closed. I'll add this to my list of "tutorials to write" and thank you very much. :D

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.