Search in sources :

Example 76 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.

the class VampireAbilityHandler method abilityHandler.

@SubscribeEvent
public void abilityHandler(PlayerTickEvent evt) {
    if (evt.phase == Phase.START && !evt.player.world.isRemote) {
        PotionEffect nv = evt.player.getActivePotionEffect(MobEffects.NIGHT_VISION);
        if ((nv == null || nv.getDuration() <= 220) && evt.player.getCapability(CapabilityTransformationData.CAPABILITY, null).isNightVisionActive()) {
            if (BewitchmentAPI.getAPI().addVampireBlood(evt.player, -2)) {
                evt.player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 300, 0, true, false));
            } else {
                evt.player.sendStatusMessage(new TextComponentTranslation("vampire.nightvision.low_blood"), true);
                evt.player.getCapability(CapabilityTransformationData.CAPABILITY, null).setNightVision(false);
            }
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) PotionEffect(net.minecraft.potion.PotionEffect) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 77 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.

the class VampireAbilityHandler method sleepBed.

@SubscribeEvent
public void sleepBed(RightClickBlock evt) {
    ITransformationData data = evt.getEntityPlayer().getCapability(CapabilityTransformationData.CAPABILITY, null);
    if (data.getType() == ModTransformations.VAMPIRE && evt.getEntityPlayer().world.getBlockState(evt.getPos()).getBlock() == Blocks.BED) {
        evt.setCancellationResult(EnumActionResult.FAIL);
        evt.setCanceled(true);
        evt.getEntityPlayer().sendStatusMessage(new TextComponentTranslation("vampire.bed_blocked"), true);
    }
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 78 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.

the class CommandFortuneActivator method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender instanceof EntityPlayer) {
        CapabilityDivination dc = ((EntityPlayer) sender).getCapability(CapabilityDivination.CAPABILITY, null);
        if (dc.getFortune() != null) {
            if (dc.isActive()) {
                throw new CommandException("commands.enable_fortune.error.already_active");
            }
            dc.setActive();
            sender.sendMessage(new TextComponentTranslation("commands.enable_fortune.success"));
        } else {
            throw new CommandException("commands.enable_fortune.error.no_fortune");
        }
    } else {
        throw new CommandException("commands.error.no_console");
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) CapabilityDivination(com.bewitchment.common.core.capability.divination.CapabilityDivination) EntityPlayer(net.minecraft.entity.player.EntityPlayer) CommandException(net.minecraft.command.CommandException)

Example 79 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.

the class CommandTransformationModifier method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0)
        throw new WrongUsageException("commands.set_transformation.usage");
    if (sender instanceof EntityPlayer) {
        String typeStr = args[0].toLowerCase();
        ITransformation transf = null;
        if (typeStr.equals("v") || typeStr.equals("vamp")) {
            transf = ModTransformations.VAMPIRE;
        } else if (typeStr.equals("w") || typeStr.equals("ww") || typeStr.equals("wolf")) {
            transf = ModTransformations.WEREWOLF;
        } else if (typeStr.equals("h") || typeStr.equals("hunt") || typeStr.equals("wh")) {
            transf = ModTransformations.HUNTER;
        } else if (typeStr.equals("s") || typeStr.equals("ghost") || typeStr.equals("phantom")) {
            transf = ModTransformations.SPECTRE;
        } else if (typeStr.equals("n")) {
            transf = ModTransformations.NONE;
        } else
            for (ITransformation tt : ModTransformations.REGISTRY) {
                if (typeStr.equals(tt.getRegistryName().getResourcePath().toLowerCase()) || typeStr.equals(tt.getRegistryName().toString().toLowerCase())) {
                    transf = tt;
                    break;
                }
            }
        if (transf == null)
            throw new WrongUsageException("commands.set_transformation.usage.no_transformation");
        int level = 0;
        try {
            if (transf != ModTransformations.NONE) {
                level = Integer.valueOf(args[1]);
            }
        } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) {
            throw new WrongUsageException("commands.set_transformation.usage.invalid_level");
        }
        if (level < 0 || level > 10) {
            throw new WrongUsageException("commands.set_transformation.usage.invalid_level");
        }
        BewitchmentAPI.getAPI().setTypeAndLevel((EntityPlayer) sender, transf, level, false);
        sender.sendMessage(new TextComponentTranslation("commands.set_transformation.success", transf.getRegistryName().toString().toLowerCase(), level));
    } else {
        throw new WrongUsageException("commands.error.no_console");
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ITransformation(com.bewitchment.api.capability.transformations.ITransformation)

Example 80 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.

the class TileEntityTarotsTable method read.

public void read(@Nonnull ItemStack tarotDeck, @Nonnull EntityPlayer reader) {
    if (!reader.world.isRemote) {
        if (checkDeck(tarotDeck) && consumePower(READ_COST, false)) {
            reader.openGui(Bewitchment.instance, LibGui.TAROT.ordinal(), reader.world, pos.getX(), pos.getY(), pos.getZ());
            NetworkHandler.HANDLER.sendTo(new TarotMessage(reader), (EntityPlayerMP) reader);
        } else {
            reader.sendStatusMessage(new TextComponentTranslation("item.tarots.error_reading"), true);
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) TarotMessage(com.bewitchment.common.core.net.messages.TarotMessage)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)502 ItemStack (net.minecraft.item.ItemStack)134 ITextComponent (net.minecraft.util.text.ITextComponent)82 EntityPlayer (net.minecraft.entity.player.EntityPlayer)72 BlockPos (net.minecraft.util.math.BlockPos)70 TextComponentString (net.minecraft.util.text.TextComponentString)66 Style (net.minecraft.util.text.Style)60 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)58 TileEntity (net.minecraft.tileentity.TileEntity)45 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)33 ArrayList (java.util.ArrayList)32 World (net.minecraft.world.World)30 IBlockState (net.minecraft.block.state.IBlockState)28 EnumFacing (net.minecraft.util.EnumFacing)26 CommandException (net.minecraft.command.CommandException)25 Block (net.minecraft.block.Block)20 Nonnull (javax.annotation.Nonnull)19 WrongUsageException (net.minecraft.command.WrongUsageException)19 EnumActionResult (net.minecraft.util.EnumActionResult)19