How to create a command that enables flight in survival?

Started by RangerRed2002 on Wed, 10/02/2019 - 03:37

Topic category: Help with MCreator modding

Last seen on 22:33, 8. Nov 2019
Joined Oct 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
How to create a command that enables flight in survival?
Wed, 10/02/2019 - 03:37

Hello. I'm trying to make a custom command which enables flight in survival. I've tried creating a command and putting the "allow entity to fly" procedure, but that doesn't seem to work. Can someone help me with this? Any help would be appreciated.

Here is the code:

package net.mcreator.herocraft;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.Entity;

import java.util.HashMap;

@Elementsherocraft.ModElement.Tag
public class MCreatorAllowflightCommandExecuted extends Elementsherocraft.ModElement {
	public MCreatorAllowflightCommandExecuted(Elementsherocraft instance) {
		super(instance, 100);
	}

	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 MCreatorAllowflightCommandExecuted!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		if (entity instanceof EntityPlayer)
			((EntityPlayer) entity).capabilities.allowFlying = (true);
	}
}

 

Last seen on 21:21, 13. Nov 2019
Joined Aug 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
You can try to do this :…
Thu, 10/03/2019 - 01:58

You can try to do this :

Create a local boolean variable (logic variable). (Variable name = Fly (for example))

If Fly = false

Do Allow provided entity to fly (Put it to TRUE)

      Set Fly to TRUE

Else if Fly = True

Do Allow provided entity to fly (Put it to FALSE)

     Set Fly to FALSE

 

I think that will work.

Last seen on 22:33, 8. Nov 2019
Joined Oct 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
I'm not saying the "Set …
Thu, 10/03/2019 - 03:11

I'm not saying the "Set [variable] to [true/false" coding block. Is this normal?