Search in sources :

Example 36 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.

the class CharsetTransportCarts method onNothingInteract.

@SubscribeEvent
public void onNothingInteract(PlayerInteractEvent.RightClickEmpty event) {
    if (!event.getEntityPlayer().getEntityWorld().isRemote && event.getItemStack().getItem() == itemLinker) {
        if (linkMap.containsKey(event.getEntityPlayer())) {
            linkMap.remove(event.getEntityPlayer());
            event.getEntityPlayer().sendMessage(new TextComponentString("dev_unlinked"));
            event.setCanceled(true);
        }
    }
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 37 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.

the class TileShelf method onActivated.

protected boolean onActivated(float hitX, float hitY, float hitZ, ItemStack stack, EntityPlayer player) {
    int slotId = getSlotId(hitX, hitY, hitZ);
    if (slotId < 0)
        return false;
    if (stack.isEmpty()) {
        if (handler.getStackInSlot(slotId).isEmpty()) {
            slotId = toNonBookSlotId(slotId);
        }
        if (!handler.getStackInSlot(slotId).isEmpty()) {
            final int sentSlotId = slotId;
            new Notice(new Vec3d(pos).addVector(hitX, hitY, hitZ), msg -> msg.withItem(handler.getStackInSlot(sentSlotId)).setMessage(new TextComponentString("{ITEM_NAME}{ITEM_INFOS_NEWLINE}"))).sendTo(player);
            return true;
        } else {
            return false;
        }
    } else {
        if (!isBook(stack))
            slotId = toNonBookSlotId(slotId);
        if (isSlotTaken(slotId))
            return false;
        stack = stack.splitStack(1);
        handler.setStackInSlot(slotId, stack);
        markBlockForUpdate();
        return true;
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemUtils(pl.asie.charset.lib.utils.ItemUtils) Constants(net.minecraftforge.common.util.Constants) Properties(pl.asie.charset.lib.Properties) UnlistedPropertyGeneric(pl.asie.charset.lib.utils.UnlistedPropertyGeneric) EnumFacing(net.minecraft.util.EnumFacing) Capability(net.minecraftforge.common.capabilities.Capability) ItemMaterial(pl.asie.charset.lib.material.ItemMaterial) TextComponentString(net.minecraft.util.text.TextComponentString) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) TileBase(pl.asie.charset.lib.block.TileBase) Vec3d(net.minecraft.util.math.Vec3d) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) INoticeUpdater(pl.asie.charset.lib.notify.INoticeUpdater) Notice(pl.asie.charset.lib.notify.Notice) EntityPlayer(net.minecraft.entity.player.EntityPlayer) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) ItemMaterialRegistry(pl.asie.charset.lib.material.ItemMaterialRegistry) ItemHandlerCharset(pl.asie.charset.lib.ui.ItemHandlerCharset) Nullable(javax.annotation.Nullable) Notice(pl.asie.charset.lib.notify.Notice) Vec3d(net.minecraft.util.math.Vec3d) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 38 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project DefiledLands by Lykrast.

the class ItemBookWyrmAnalyzer method itemInteractionForEntity.

/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) {
    if (entity.world.isRemote) {
        return false;
    }
    if (entity instanceof EntityBookWyrm) {
        EntityBookWyrm target = (EntityBookWyrm) entity;
        String base = "ui.defiledlands.book_wyrm_analyze.";
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "health")) + (int) target.getHealth() + "/" + (int) target.getMaxHealth()));
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digest_time")) + target.getDigestTime()));
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "max_level")) + target.getMaxLevel()));
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digested")) + target.digested));
        if (target.digesting > 0)
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digesting")) + target.digesting + I18n.translateToLocal(String.format("%s%s", base, "levels"))));
        if (target.isChild()) {
            int minutes = (int) Math.ceil((-target.getGrowingAge()) / 1200.0D);
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "maturing")) + minutes + I18n.translateToLocal(String.format("%s%s", base, "minutes"))));
        } else if (target.getGrowingAge() > 0) {
            int minutes = (int) Math.ceil(target.getGrowingAge() / 1200.0D);
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "reproduce")) + minutes + I18n.translateToLocal(String.format("%s%s", base, "minutes"))));
        } else
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "ready"))));
        if (target.isGolden())
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "golden"))));
        return true;
    }
    return false;
}
Also used : EntityBookWyrm(lykrast.defiledlands.common.entity.passive.EntityBookWyrm) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 39 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.

the class CommandMutter method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (!(sender instanceof TileEntity || sender instanceof Entity)) {
        return;
    }
    EnumSet theStyle = EnumSet.noneOf(NoticeStyle.class);
    ItemStack heldItem = ItemStack.EMPTY;
    if (sender instanceof EntityLivingBase) {
        heldItem = ((EntityLivingBase) sender).getHeldItem(EnumHand.MAIN_HAND);
    }
    ItemStack sendItem = ItemStack.EMPTY;
    for (int i = 0; i < args.length; i++) {
        String s = args[i];
        if (s.equalsIgnoreCase("--long")) {
            theStyle.add(NoticeStyle.LONG);
        } else if (s.equalsIgnoreCase("--show-item") && !heldItem.isEmpty()) {
            theStyle.add(NoticeStyle.DRAWITEM);
            sendItem = heldItem;
        } else {
            break;
        }
        args[i] = null;
    }
    String msg = Joiner.on(" ").skipNulls().join(args);
    msg = msg.replace("\\n", "\n");
    new Notice(sender, new TextComponentString(msg)).withStyle(theStyle).withItem(sendItem).sendToAll();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EnumSet(java.util.EnumSet) EntityLivingBase(net.minecraft.entity.EntityLivingBase) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 40 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.

the class Notice method clear.

/**
 * Erases all Notifications a player has.
 */
public static void clear(EntityPlayer player) {
    NotificationCoord at = new NotificationCoord(player.world, new BlockPos(player));
    NotifyImplementation.instance.doSend(player, at, player.world, EnumSet.of(NoticeStyle.CLEAR), null, new TextComponentString(""));
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)343 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 ItemStack (net.minecraft.item.ItemStack)68 BlockPos (net.minecraft.util.math.BlockPos)60 ITextComponent (net.minecraft.util.text.ITextComponent)48 TileEntity (net.minecraft.tileentity.TileEntity)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)35 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)32 Colony (com.minecolonies.coremod.colony.Colony)26 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)26 IBlockState (net.minecraft.block.state.IBlockState)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 Style (net.minecraft.util.text.Style)21 IColony (com.minecolonies.api.colony.IColony)19 ClickEvent (net.minecraft.util.text.event.ClickEvent)19 Entity (net.minecraft.entity.Entity)18 Block (net.minecraft.block.Block)17 World (net.minecraft.world.World)17 ArrayList (java.util.ArrayList)16 ActionResult (net.minecraft.util.ActionResult)13