Hello,
I do not know if this is normal, when I put number (in the game) to fly speed, brand myself it to change, but I am forced to restart the world. For the speed, i don't need reload world.
Is this normal? A there a solution?
My code :
package com.BlockU.blocks.command;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
public class CommandFlySpeed extends CommandBase{
@Override
public String getName() {
return "Fly";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "/Fly";
}
@Override
public void execute(ICommandSender sender, String[] args) throws CommandException {
if (args.length < 2)
{
EntityPlayer player = (EntityPlayer) sender;
String str = args[0];
int i = Integer.parseInt(str);
Integer a = Integer.valueOf(str);
player.capabilities.setFlySpeed(a);
player.setSprinting(true);
player.addChatMessage(new ChatComponentText (EnumChatFormatting.GREEN + "La vitesse de vol a été augementé de" + args[0]));
} else{
sender.addChatMessage(new ChatComponentText (EnumChatFormatting.RED + "Erreur"));
}
}
}
Thank you for your help
Ps: Thanks diesieben07, I managed with Args D