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

So I was wondering how can I spawn a custom particle when my tile entity is right-clicked? Do I need a handler or something to register particles and how can I link the particle to the tile entity?

Normally you would use-

public void randomDisplayTick(World world, int x, int y, int z, Random rand)

Go and check out Minecraft's BlockFire.class, it spawns a particle at a psuedo-random location whenever the above method is called.

 

But since you want it to spawn when the block is right-clicked, instead of randomly, spawn the particle in-

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float x1, float y1, float z1)

(check if "world.isRemote" and note that this is in Block.class not TileEntity.class)

 

To spawn a custom particle instead of one of the vanilla ones-

Minecraft.getMinecraft().effectRenderer.addEffect(new CustomFX(args...));

stick some more coherent arguments in there and CustomFX will need to extend EntityFX.

 

There aren't any handlers involved unless I'm just losing it. I would say that creating a custom particle can be somewhat non-trivial though. There are tutorials for it floating around somewhere.

  • Author

I put this Minecraft.getMinecraft() line on the onBlockActivated? And where does my particle textures go? Should I register the particles somewhere? Thanks BTW

From what I gathered in MoxEmerald's reply, you need to make a custom class, in the example he has it called CustomFX. This class will need to extend EntityFX. You can look at the BlockFire class for an example on how a particle is created. After that, you would put the

Minecraft.getMinecraft().effectRenderer.addEffect(new CustomFX(args...));

in the onBlockActivated() method.

 

You also shouldn't need to register particles, just make sure you are calling them on the client instead of the server. As for the textures, you can probably find in the BlockFire class.

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.