How do I make my sword onItemRightClick be set on fire? Like Tihyo's Human Torch (Flame on) from Superheroes Unlimited Mod, except that instead of a keybinding, I want to use the right click to set it on fire and when I want it to be gone, I click right click again.
make a boolean switch and set it to true/false when the sword is clicked.
relying on that boolean set the entity fire value to a very high value (to the max Integer.MAX_VALUE/20) (because in setfire function it will be multiplied by 20 that's the tick rate) and set it to 0 when the state is not equal.
set Entity in fire by using Entity.setFire(int) .
Remember to save the boolean or when the world reloads it will be resetted.
Keep in mind that Items are singletons, so you can't store this in a field of your Item class. Either store it in the ItemStack's NBT (if the flag is per-stack) or in an IExtendedEntityProperties (if the flag is per-entity).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Keep in mind that Items are singletons, so you can't store this in a field of your Item class. Either store it in the ItemStack's NBT (if the flag is per-stack) or in an IExtendedEntityProperties (if the flag is per-entity).
Ops, I forgot every time this detail
sorry for the bad answer, you need to save the boolean directly to nbt
make a boolean switch and set it to true/false when the sword is clicked.
relying on that boolean set the entity fire value to a very high value (to the max Integer.MAX_VALUE/20) (because in setfire function it will be multiplied by 20 that's the tick rate) and set it to 0 when the state is not equal.
set Entity in fire by using Entity.setFire(int) .
Remember to save the boolean or when the world reloads it will be resetted.
Entity#setFire can only add ticks. Using Entity#setFire(Integer.MAX_VALUE/20) will work, but Entity#setFire(0) will not "clear" the current fire amount. Instead of setting some variable in setFire, the code can only add the parameter value.
In short, use the Item's update tick method (forgot what it's called) to check the NBT boolean and call Entity#setFire(1) every 20 ticks if the flag is true.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
How do I make my sword onItemRightClick be set on fire? Like Tihyo's Human Torch (Flame on) from Superheroes Unlimited Mod, except that instead of a keybinding, I want to use the right click to set it on fire and when I want it to be gone, I click right click again.
make a boolean switch and set it to true/false when the sword is clicked.
relying on that boolean set the entity fire value to a very high value (to the max Integer.MAX_VALUE/20) (because in setfire function it will be multiplied by 20 that's the tick rate) and set it to 0 when the state is not equal.
set Entity in fire by using Entity.setFire(int) .
Remember to save the boolean or when the world reloads it will be resetted.
sorry for my bad english I'm Italian
Keep in mind that Items are singletons, so you can't store this in a field of your Item class. Either store it in the ItemStack's NBT (if the flag is per-stack) or in an IExtendedEntityProperties (if the flag is per-entity).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ops, I forgot every time this detail
sorry for the bad answer, you need to save the boolean directly to nbt
sorry for my bad english I'm Italian
Entity#setFire can only add ticks. Using Entity#setFire(Integer.MAX_VALUE/20) will work, but Entity#setFire(0) will not "clear" the current fire amount. Instead of setting some variable in setFire, the code can only add the parameter value.
In short, use the Item's update tick method (forgot what it's called) to check the NBT boolean and call Entity#setFire(1) every 20 ticks if the flag is true.