I'm currently trying to get into modding and i started with a videogame abilities mod. I already finished the rocketjump, but i also want it to spawn a particle effect beneath the player. Here is my current code:
public ItemStack onItemRightClick(ItemStack itemStack, World worldIn, EntityPlayer player)
{
if (this.ability == 0)
{
player.jump();
player.addPotionEffect(new PotionEffect(23, 1, 0));
itemStack.damageItem(1, player);
player.fallDistance = 0F;
}
return itemStack;
I have tried looking at " worldIn.spawnParticle(particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, p_175688_14_); " but i don't really understand how i can make that work, as the coordinates have to be relative to the player. I think it could be possible by first getting the current player coordinates and then setting them as xCoord, yCoord, ... and removing 1 from the yCoord, but I don't really have a clue on how to do that.
I also don't really understand what the last part is about.
The last four argument are particle type specific. You can refer to the particle command for details. (xd yd and zd are the xOffset yOffset and zOffset arguments, and params is the p_175688_14_ argument).
First of all, thanks, but I'm still getting an error message for magicCrit, xCoord, yCoord, zCoord and p_185688_14_. They can't be resolved to a variable for magicCrit and p_185688_14_ and for the coords that they can't be resolved or that they aren't a field.
xCoord, etc. also can't be found when I search for them via autocompletion
(Maybe I should have just copy and pasted the relevant info from the article rather than linking)
The first argument is a String, so you will have to put "magicCrit" (including the quotes). For an entity, such as a player, the fields are called posX, posY and posZ. That last argument (p_185688_14_) is varargs, so you can just remove the last parameter, so that:
in 1.8 the first argument is not a string but it became an Enum: simply put EnumParticleTypes.CRIT_MAGIC as first argument, and finally the param p_175688_14_ is required because there is only one method to spawn particle and it requires it World#spawnParticle(EnumParticleTypes, double, double, double, double, double, double, int ...).
you don't need params to spawn magicCrit then you can put null as last argument.
Hello,
I'm currently trying to get into modding and i started with a videogame abilities mod. I already finished the rocketjump, but i also want it to spawn a particle effect beneath the player. Here is my current code:
I have tried looking at " worldIn.spawnParticle(particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, p_175688_14_); " but i don't really understand how i can make that work, as the coordinates have to be relative to the player. I think it could be possible by first getting the current player coordinates and then setting them as xCoord, yCoord, ... and removing 1 from the yCoord, but I don't really have a clue on how to do that.
I also don't really understand what the last part is about.
Maybe I'm just approaching this wrong?
Any help is greatly appreciated!
~towind
The last four argument are particle type specific. You can refer to the particle command for details. (xd yd and zd are the xOffset yOffset and zOffset arguments, and params is the p_175688_14_ argument).
Ok, so I adjusted the line to this:
(If the color offset won't fit, I'll change it later)
It's still giving me an error for the params argument. Should i set it to 0?
this should work spawning particles at player's base
and remember, you cant use tilda (~) in java
sorry for my bad english I'm Italian
First of all, thanks, but I'm still getting an error message for magicCrit, xCoord, yCoord, zCoord and p_185688_14_. They can't be resolved to a variable for magicCrit and p_185688_14_ and for the coords that they can't be resolved or that they aren't a field.
xCoord, etc. also can't be found when I search for them via autocompletion
(Maybe I should have just copy and pasted the relevant info from the article rather than linking)
The first argument is a String, so you will have to put "magicCrit" (including the quotes). For an entity, such as a player, the fields are called posX, posY and posZ. That last argument (p_185688_14_) is varargs, so you can just remove the last parameter, so that:
becomes:
(This ignores the other changes I mentioned)
ops sorry for my fails
then the final code is:
ah and xCoord yCoord zCoord are for tile entity position xD
my fail
sorry for my bad english I'm Italian
Thanks, but I'm still getting an error message that the method
spawnParticle(EnumParticleTypes, double, double, double, double, double, double, int...)
in the type World is not applicable for the arguments
(String, double, double, double, int, int, int).
If remove the " from magicCrit it says that it can't be resolved into a variable.
Sorry for not responding that early
in 1.8 the first argument is not a string but it became an Enum: simply put EnumParticleTypes.CRIT_MAGIC as first argument, and finally the param p_175688_14_ is required because there is only one method to spawn particle and it requires it World#spawnParticle(EnumParticleTypes, double, double, double, double, double, double, int ...).
you don't need params to spawn magicCrit then you can put null as last argument.
the final code will be
P.S. I tried that and it worked on my workspace
sorry for my bad english I'm Italian
Thank you very much! It works for me too and i understand how it works now!
I'm glad I helped you
sorry for my bad english I'm Italian