Started by
RangerRed2002
on
Topic category: Help with Minecraft modding (Java Edition)
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 :
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.
I'm not saying the "Set [variable] to [true/false" coding block. Is this normal?