Flying armor procedure

Published by mike201402 on Sat, 02/16/2019 - 21:14
Status
Fixed
Product/platform
MCreator/Windows
Priority
Normal
Issue description

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

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.

Good to know, but that still doesn't solve the problem with being able to fly while not using the armor

I really need your help, i'm looking for a way to do this for ages and still I haven't found a solution

Below is the code I got after making this procedure:

 

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);
		}
	}
}

 

How do you trigger this procedure? Consider using a global procedure trigger called On player tick update. This could actually make this work :)

For anyone looking for this. Here is a very simplified version that checks if the player is wearing a helmet and if so, allows flight.

image

Mike,

Not sure if you ever got an answer to this, but the trick is very simple to get it to work when wearing it, and to stop when you take it off.

Simple fix

this works, it was mostly about adding in on global player tick, then this works great tested it and working 100%

this procedure its that good. if u dot have the chestplate equipped and ur in creative, u cant fly, or if u have another mod that add flying armor, u still wont be able to fly



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.