Hi, since I couldn't get someone to help me in the forums ill ask it here.
I'm trying to make a mod that adds armor that let you fly, I made a procedure, added it to the boots and it worked but for some reason even after I took the boots off I could still fly.
Is there any way to fix this or can anyone send me a picture of a procedure that works?
And one other thing, if possible I will be happy if anyone will be able to also show me how to make it that the player will need to wear a full armor set in order to get some sort of bonus like a potion effect.
thanks in advance and have a nice day.
Please note: I did a lot of searching before opening this issue and I couldn't find an answer that helped me so i'm pretty sure this isn't a duplicate.
Issue comments
Below is the code I got after making this procedure:
Maybe you can tell what is causing the issue? (I noticed the ''allow entity to fly'' part of the procedure says in the end ''otherwise don't'' but that doesn't seems to have any effect on the procedure and the result no matter what so I just ignored it)
Code:
public class mcreator_fly extends test.ModElement {
public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
if (dependencies.get("entity") == null) {
System.err.println("Failed to load dependency entity for procedure fly!");
return;
}
Entity entity = (Entity) dependencies.get("entity");
if (((entity instanceof EntityLivingBase)
? ((EntityPlayer) entity).inventory.hasItemStack(new ItemStack(mcreator_test.boots, (int) (1)))
: false)) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).capabilities.allowFlying = (true);
} else if ((!((entity instanceof EntityLivingBase) ? ((EntityPlayer) entity).inventory.hasItemStack(new ItemStack(mcreator_test.boots,
(int) (1))) : false))) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).capabilities.allowFlying = (false);
}
}
}
Image can't be seen, check https://mcreator.net/wiki/how-post-images-website ;)
Right now you can only make armor to give you effect by giving potion effects with a duration of one tick to the player. This way potion effect is only updated for the next tick and if the armor is not in the use anymore, the potion expires.
We will consider improving this in the future.