How to create a command that enables flight in survival?

Started by RangerRed2002 on

Topic category: Help with modding (Java Edition)

Last seen on 00:49, 25. Jun 2021
Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to create a command that enables flight in survival?

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

 

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 00:49, 25. Jun 2021
Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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?