Started by
RangerRed2002
on
Topic category: Help with Minecraft modding (Java Edition)
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);
}
}
Try to enable flying with a command block instead.
How would I make that a normal command though? Details would help.
I am not sure, It was just an idea. Minecraft Wiki might help.