Search in sources :

Example 6 with CapabilityDivination

use of com.bewitchment.common.core.capability.divination.CapabilityDivination in project Bewitchment by Um-Mitternacht.

the class CommandForceFortune method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0)
        throw new WrongUsageException("commands.set_fortune.usage");
    if (sender instanceof EntityPlayer) {
        CapabilityDivination dc = ((EntityPlayer) sender).getCapability(CapabilityDivination.CAPABILITY, null);
        IFortune add = Fortune.REGISTRY.getValue(new ResourceLocation(args[0]));
        if (add == null) {
            throw new CommandException("commands.set_fortune.error.no_fortune");
        }
        dc.setFortune(add);
        sender.sendMessage(new TextComponentTranslation("commands.set_fortune.success"));
    } else {
        throw new CommandException("commands.error.no_console");
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) CapabilityDivination(com.bewitchment.common.core.capability.divination.CapabilityDivination) ResourceLocation(net.minecraft.util.ResourceLocation) IFortune(com.bewitchment.api.divination.IFortune) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

CapabilityDivination (com.bewitchment.common.core.capability.divination.CapabilityDivination)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Block (net.minecraft.block.Block)3 ItemStack (net.minecraft.item.ItemStack)3 LootContext (net.minecraft.world.storage.loot.LootContext)3 LootTable (net.minecraft.world.storage.loot.LootTable)3 IFortune (com.bewitchment.api.divination.IFortune)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 CommandException (net.minecraft.command.CommandException)1 ResourceLocation (net.minecraft.util.ResourceLocation)1