I followed Jabelar's tutorial on Custom Particles here and I'm having difficulty at the last part of his tutorial at the proxy part where the parameters of my particle class constructor are added and replace them with values. Here's my custom particle class and clientproxy generateparticles method link. I hope
The first three lines give the particle a random motion. This is essential because otherwise the particle will stay exactly where you spawn it and will not be noticeable.
Jabelar calls the same thing for each motion variable:
theEntity.worldObj.rand.nextGaussian() * 0.02D;
Pretty simple, and there are many alternatives (rand.nextFloat, rand.nextDouble, etc.) The advantage of nextGaussian is that it tends to pick numbers closer to zero than further -- numbers "group" and the result can be shifted or transformed as needed. In this case the motion will be very small because the result is multiplied by 0.02
The next part combines the constructor and position randomness. It is also crucial to not spawn all your particles at the entity's exact position, so let's look at one position statement:
This is the first parameter in the constructor and is identical to the third except that it uses posX instead of posZ. Remember the order of operations: The second, third, and fourth parts of this line will be calculated. For example, replace it with a variable called spreadX and you get:
theEntity.posX + spreadX - theEntity.width
That makes it easier to see that all it does is take the entity position, add a random value, and subtract the entity width.
The same thing is done for the y position but using theEntity.height instead.
The next three args after the world and position are your motion values that you set in the first three lines. Not too hard, really.
If it's instantiating your particle, read here:
Your constructor in EntityParticleYellow has autogenerated names like this:
The first argument is the world. The second, third, and fourth args are posX, posY, and posZ respectively. The last three args are motionX, motionY, and motionZ in that order.
Inside the "other stuff," check out what the super class does in its constructor. For example,
this.setRBGColorF(0xff, 0xff, 0x00);
This sets the color to full red, full blue, and no green, which give us yellow. I'm sure you already know this, though.
For actually making an instance of your EntityFX, the constructor expects something like this:
new EntityParticleYellow(world, positionX, positionY, positionZ, motionX, motionY, motionZ);
That's all I've got unless you specify the exact problem. Hopefully this helps though.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
So I cleaned up the code to help me understand with replacing the functions in the parameter to the "english" version, and added in the motions in the instantiating in my client proxy. So I want to spawn the custom particle on blocks, I know how do them, just how do I call it? Here's the spawning method (copied it from the redstone block class). Link for spawning method and link for the updated client proxy and entity particle class.
You don't seem to call activate or spawnParticles from anywhere. May I suggest calling them from this method:
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, Random rand)
{
spawnParticles(world, pos);
}
I'm not sure these are the correct parameters or method name. Look in BlockPortal and BlockRedstone for a similarly named method if putting @Override throws an error.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
That method doesn't exists from the parent class Block so it appears that it is the BlockPortal and BockRedstone's own method. So how do I call the my particle?
Sorry, I wrote that method from memory and, like I though, left out a parameter. The full method to override is in Block:
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
// do your stuff here
}
The missing parameter was IBlockState state. If you used Eclipse to search the Block class for a method called randomDisplayTick it would have found this.
randomDisplayTick is called once every one to ten ticks for every block.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
I followed Jabelar's tutorial on Custom Particles here and I'm having difficulty at the last part of his tutorial at the proxy part where the parameters of my particle class constructor are added and replace them with values. Here's my custom particle class and clientproxy generateparticles method link. I hope
I didn't make it confusing.
What difficulties are you having?
If it's the long complicated math in generateParticles that throws you off, read here:
Jabelar gives this as an example:
Let's break it up:
The first three lines give the particle a random motion. This is essential because otherwise the particle will stay exactly where you spawn it and will not be noticeable.
Jabelar calls the same thing for each motion variable:
Pretty simple, and there are many alternatives (rand.nextFloat, rand.nextDouble, etc.) The advantage of nextGaussian is that it tends to pick numbers closer to zero than further -- numbers "group" and the result can be shifted or transformed as needed. In this case the motion will be very small because the result is multiplied by 0.02
The next part combines the constructor and position randomness. It is also crucial to not spawn all your particles at the entity's exact position, so let's look at one position statement:
This is the first parameter in the constructor and is identical to the third except that it uses posX instead of posZ. Remember the order of operations: The second, third, and fourth parts of this line will be calculated. For example, replace it with a variable called spreadX and you get:
That makes it easier to see that all it does is take the entity position, add a random value, and subtract the entity width.
The same thing is done for the y position but using theEntity.height instead.
The next three args after the world and position are your motion values that you set in the first three lines. Not too hard, really.
If it's instantiating your particle, read here:
Your constructor in EntityParticleYellow has autogenerated names like this:
The first argument is the world. The second, third, and fourth args are posX, posY, and posZ respectively. The last three args are motionX, motionY, and motionZ in that order.
Inside the "other stuff," check out what the super class does in its constructor. For example,
This sets the color to full red, full blue, and no green, which give us yellow. I'm sure you already know this, though.
For actually making an instance of your EntityFX, the constructor expects something like this:
That's all I've got unless you specify the exact problem. Hopefully this helps though.
So I cleaned up the code to help me understand with replacing the functions in the parameter to the "english" version, and added in the motions in the instantiating in my client proxy. So I want to spawn the custom particle on blocks, I know how do them, just how do I call it? Here's the spawning method (copied it from the redstone block class). Link for spawning method and link for the updated client proxy and entity particle class.
You don't seem to call activate or spawnParticles from anywhere. May I suggest calling them from this method:
I'm not sure these are the correct parameters or method name. Look in BlockPortal and BlockRedstone for a similarly named method if putting @Override throws an error.
That method doesn't exists from the parent class Block so it appears that it is the BlockPortal and BockRedstone's own method. So how do I call the my particle?
Sorry, I wrote that method from memory and, like I though, left out a parameter. The full method to override is in Block:
The missing parameter was IBlockState state. If you used Eclipse to search the Block class for a method called randomDisplayTick it would have found this.
randomDisplayTick is called once every one to ten ticks for every block.