Posted May 18, 201411 yr 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?
May 18, 201411 yr 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.
May 22, 201411 yr 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
May 22, 201411 yr 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.