Jump to content

Recommended Posts

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?

Posted

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.

Posted

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

Posted

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

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