mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 01:12:13 +02:00
Merge #7
This commit is contained in:
commit
a8f5ce1c21
@ -26,7 +26,7 @@ public final class CmdList
|
||||
public final CopyItemCmd copyitemCmd = new CopyItemCmd();
|
||||
// public final DamageCmd damageCmd = new DamageCmd();
|
||||
public final DropCmd dropCmd = new DropCmd();
|
||||
// public final EnchantCmd enchantCmd = new EnchantCmd();
|
||||
public final EnchantCmd enchantCmd = new EnchantCmd();
|
||||
// public final ExcavateCmd excavateCmd = new ExcavateCmd();
|
||||
// public final FeaturesCmd featuresCmd = new FeaturesCmd();
|
||||
// public final FollowCmd followCmd = new FollowCmd();
|
||||
|
77
src/main/java/net/wurstclient/commands/EnchantCmd.java
Normal file
77
src/main/java/net/wurstclient/commands/EnchantCmd.java
Normal file
@ -0,0 +1,77 @@
|
||||
package net.wurstclient.commands;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.wurstclient.command.CmdError;
|
||||
import net.wurstclient.command.CmdException;
|
||||
import net.wurstclient.command.CmdSyntaxError;
|
||||
import net.wurstclient.command.Command;
|
||||
import net.wurstclient.util.ChatUtils;
|
||||
|
||||
public final class EnchantCmd extends Command
|
||||
{
|
||||
public EnchantCmd()
|
||||
{
|
||||
super("enchant", "Enchants an item with everything,\n"
|
||||
+ "except for silk touch and curses.", ".enchant");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(String[] args) throws CmdException
|
||||
{
|
||||
if(!MC.player.abilities.creativeMode)
|
||||
throw new CmdError("Creative mode only.");
|
||||
|
||||
if(args.length > 1)
|
||||
throw new CmdSyntaxError();
|
||||
|
||||
ItemStack stack = getHeldItem();
|
||||
enchant(stack);
|
||||
|
||||
ChatUtils.message("Item enchanted.");
|
||||
}
|
||||
|
||||
private ItemStack getHeldItem() throws CmdError
|
||||
{
|
||||
ItemStack stack = MC.player.inventory.getMainHandStack();
|
||||
|
||||
if(stack.isEmpty())
|
||||
throw new CmdError("There is no item in your hand.");
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void enchant(ItemStack stack)
|
||||
{
|
||||
for(Enchantment enchantment : Registry.ENCHANTMENT)
|
||||
{
|
||||
if(enchantment == Enchantments.SILK_TOUCH)
|
||||
continue;
|
||||
|
||||
if(enchantment.isCursed())
|
||||
continue;
|
||||
|
||||
if(enchantment == Enchantments.QUICK_CHARGE)
|
||||
{
|
||||
stack.addEnchantment(enchantment, 5);
|
||||
continue;
|
||||
}
|
||||
|
||||
stack.addEnchantment(enchantment, 127);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryAction()
|
||||
{
|
||||
return "Enchant Held Item";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPrimaryAction()
|
||||
{
|
||||
WURST.getCmdProcessor().process("enchant");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user