"Allow Flight" procedure not working?

Started by RangerRed2002 on Wed, 10/02/2019 - 01:24

Topic category: Help with modding (Java Edition)

Last seen on 04:45, 2. Jun 2020
Joined Oct 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
"Allow Flight" procedure not working?
Wed, 10/02/2019 - 01:24

Hello. I created a block with a GUI that has buttons that give you abilities. I'm able to get potion effects from it using the procedures, but I'm not able to get the "allow flight" procedure to work. If I add that procedure to an item or armor, then it works fine and I'm able to fly. But whenever it's activated via a GUI button, it doesn't work. Can anyone help me with this?

Bellow is my source code:

package net.mcreator.herocraft;

import net.minecraft.potion.PotionEffect;
import net.minecraft.init.MobEffects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;

import java.util.HashMap;

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

	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 MCreatorMetamachineguiOnButtonClicked1!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		if (entity instanceof EntityLivingBase)
			((EntityLivingBase) entity).clearActivePotions();
		if (entity instanceof EntityLivingBase)
			((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.STRENGTH, (int) 1000000, (int) 1, (false), (false)));
		if (entity instanceof EntityLivingBase)
			((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SPEED, (int) 1000000, (int) 1, (false), (false)));
		if (entity instanceof EntityLivingBase)
			((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int) 1000000, (int) 0, (false), (false)));
		if (entity instanceof EntityLivingBase)
			((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, (int) 1000000, (int) 0, (false), (false)));
		if (entity instanceof EntityPlayer)
			((EntityPlayer) entity).capabilities.allowFlying = (true);
	}
}

 

Last seen on 04:45, 2. Jun 2020
Joined Oct 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
How would I make that a…
Wed, 10/02/2019 - 19:15

How would I make that a normal command though? Details would help.