当前位置: 首页>>代码示例>>Java>>正文


Java TextComponentTranslation类代码示例

本文整理汇总了Java中net.minecraft.util.text.TextComponentTranslation的典型用法代码示例。如果您正苦于以下问题:Java TextComponentTranslation类的具体用法?Java TextComponentTranslation怎么用?Java TextComponentTranslation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextComponentTranslation类属于net.minecraft.util.text包,在下文中一共展示了TextComponentTranslation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    new Thread(() -> {
        try {
            byte[] dataToDump = FullwidthPunctuationFix.INSTANCE.getCharWidthData();
            File dest = new File(Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks(), "autogen_glyph_width");
            if (!dest.exists() || !dest.isDirectory()) {
                dest.mkdir();
            }
            File dumpTargetDir = new File(dest, "assets/minecraft/font");
            if (!dumpTargetDir.exists() || !dumpTargetDir.isDirectory()) {
                dumpTargetDir.mkdirs();
            }
            File dumpTarget = new File(dumpTargetDir, "glyph_sizes.bin");
            FileUtils.writeByteArrayToFile(dumpTarget, dataToDump, false);
            File packMeta = new File(dest, "pack.mcmeta");
            FileUtils.writeStringToFile(packMeta, "{ \"pack\": { \"pack_format\": 2, \"description\": \"Auto-generated glyph width data\" } }", "UTF-8", false);
            sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.success"));
        } catch (Exception e) {
            sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.fail"));
        }
    }, "GlyphWidthDataExporter").start();
}
 
开发者ID:Team-AbCiv,项目名称:FullwidthPunctuationFix,代码行数:24,代码来源:CommandDumpGlyphWidth.java

示例2: onItemUse

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

	if (!worldIn.isRemote) {
		if(!facing.equals(EnumFacing.UP)){
			playerIn.addChatComponentMessage(new TextComponentTranslation("chat.tripod.mustup"));
			return EnumActionResult.PASS;
		}
		Entity entity = new EntityTripod(worldIn);
		entity.setPositionAndUpdate(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
		entity.rotationYaw = playerIn.rotationYaw;
		entity.rotationPitch = playerIn.rotationPitch;
		worldIn.spawnEntityInWorld(entity);
		// worldIn.updateEntities();
		stack.stackSize--;
		return EnumActionResult.SUCCESS;
	}
	return EnumActionResult.PASS;
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:21,代码来源:ItemTripod.java

示例3: entityInteract

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@SubscribeEvent
public void entityInteract(EntityInteract event) {
	if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera")) {
		event.setCanceled(true);
		if (event.getSide().isClient() && event.getHand().equals(EnumHand.MAIN_HAND)
				&& event.getItemStack() == null) {
			System.out.println("EntityInteract,HandType=" + event.getHand());
			ActiveTripod(Minecraft.getMinecraft().thePlayer.getName(),
					((EntityTripod) event.getWorld()
							.getEntityByID(event.getEntityPlayer().getEntityData().getInteger("renderViewCamera")))
									.getDelay());
		}
		return;
	}
	if (event.getTarget() instanceof EntityTripod) {
		Entity target = ((PlayerInteractEvent.EntityInteract) event).getTarget();
		EntityPlayer player = event.getEntityPlayer();
		if (!player.isSneaking()) {
			if (player.inventory.armorInventory[3] != null
					&& player.inventory.armorInventory[3].getItem() instanceof ItemGlassesHelmet) {
				if (player.getEntityWorld().isRemote) {
					// System.out.println("123");
					Minecraft.getMinecraft().setRenderViewEntity(target);
					Minecraft.getMinecraft().ingameGUI.setRecordPlaying(new TextComponentTranslation("chat.tripod.info"), false);
				}
				player.getEntityData().setInteger("renderViewCamera", target.getEntityId());
			}else if(!event.getWorld().isRemote&&event.getHand().equals(EnumHand.MAIN_HAND)){
				player.addChatComponentMessage(new TextComponentTranslation("chat.tripod.mustuseglass"));
			}
		} else {
			player.getEntityData().setInteger("usingGui", target.getEntityId());
			player.openGui(MineCamera.instance, GuiElementLoader.GUI_TRIPOD_CAMERA, target.getEntityWorld(),
					(int) target.posX, (int) target.posY, (int) target.posZ);
		}
	}
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:37,代码来源:EventLoader.java

示例4: handleServerSide

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public void handleServerSide(PacketAmadronTradeAdd message, EntityPlayer player) {
    AmadronOfferCustom offer = message.getOffer();
    offer.updatePlayerId();
    if (AmadronOfferManager.getInstance().hasOffer(offer.copy().invert())) {
        player.sendStatusMessage(new TextComponentTranslation("message.amadron.duplicateReversedOffer"), false);
    } else if (AmadronOfferManager.getInstance().addStaticOffer(offer)) {
        if (AmadronOfferSettings.notifyOfTradeAddition) NetworkHandler.sendToAll(message);
        try {
            AmadronOfferStaticConfig.INSTANCE.writeToFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        player.sendStatusMessage(new TextComponentTranslation("message.amadron.duplicateOffer"), false);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:PacketAmadronTradeAdd.java

示例5: initStats

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
private static void initStats()
{
    for (Item item : Item.REGISTRY)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null)
            {
                OBJECT_USE_STATS[i] = (new StatCrafting("stat.useItem.", s, new TextComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();

                if (!(item instanceof ItemBlock))
                {
                    USE_ITEM_STATS.add((StatCrafting)OBJECT_USE_STATS[i]);
                }
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_USE_STATS);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:StatList.java

示例6: itemInteractionForEntity

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack iStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
    if (!player.world.isRemote) {
        if (entity instanceof IManoMeasurable) {
            if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
                List<String> curInfo = new ArrayList<String>();
                ((IManoMeasurable) entity).printManometerMessage(player, curInfo);
                if (curInfo.size() > 0) {
                    ((IPressurizable) iStack.getItem()).addAir(iStack, -30);
                    for (String s : curInfo) {
                        player.sendStatusMessage(new TextComponentTranslation(s), false);
                    }
                    return true;
                }
            } else {
                player.sendStatusMessage(new TextComponentTranslation(TextFormatting.RED + "The Manometer doesn't have any charge!"), false);
            }
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:22,代码来源:ItemManometer.java

示例7: initItemDepleteStats

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
private static void initItemDepleteStats()
{
    for (Item item : Item.REGISTRY)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null && item.isDamageable())
            {
                OBJECT_BREAK_STATS[i] = (new StatCrafting("stat.breakItem.", s, new TextComponentTranslation("stat.breakItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_BREAK_STATS);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:StatList.java

示例8: isEntityTypeValid

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
private static <T extends Entity> boolean isEntityTypeValid(ICommandSender commandSender, Map<String, String> params)
{
    String s = getArgument(params, "type");
    s = s != null && s.startsWith("!") ? s.substring(1) : s;

    if (s != null && !EntityList.isStringValidEntityName(s))
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.generic.entity.invalidType", new Object[] {s});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        commandSender.addChatMessage(textcomponenttranslation);
        return false;
    }
    else
    {
        return true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:EntitySelector.java

示例9: drawForegroundLayer

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public void drawForegroundLayer(BasicTeslaGuiContainer container, int guiX, int guiY, int mouseX, int mouseY) {
    super.drawForegroundLayer(container, guiX, guiY, mouseX, mouseY);
    if (this.tile != null) {
        long timeLeft = 0;
        long generatingRate = 0;
        if (this.tile.getGeneratedPowerStored() > 0) {
            timeLeft = ((this.tile.getGeneratedPowerStored() / 2) / this.tile.getGeneratedPowerReleaseRate()) / 20;
            generatingRate = this.tile.getGeneratedPowerReleaseRate();
        }
        FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
        GlStateManager.pushMatrix();
        GlStateManager.translate(this.getLeft() + 2, this.getTop() + 2, 0);
        GlStateManager.scale(1, 1, 1);
        renderer.drawString(TextFormatting.DARK_GRAY + new TextComponentTranslation("text.industrialforegoing.display.burning").getFormattedText(), 4, 4, 0xFFFFFF);
        renderer.drawString(TextFormatting.DARK_GRAY + getFormatedTime(timeLeft * 1000), 8, (renderer.FONT_HEIGHT) + 5, 0xFFFFFF);
        renderer.drawString(TextFormatting.DARK_GRAY + new TextComponentTranslation("text.industrialforegoing.display.producing").getFormattedText(), 4, 2 * (renderer.FONT_HEIGHT) + 9, 0xFFFFFF);
        renderer.drawString(TextFormatting.DARK_GRAY + "" + generatingRate + " RF/tick", 8, 3 * (renderer.FONT_HEIGHT) + 10, 0xFFFFFF);
        GlStateManager.popMatrix();
    }
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:22,代码来源:PetrifiedFuelInfoPiece.java

示例10: onBlockActivated

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) 
{
	if(!worldIn.isRemote)
		if(((Boolean)state.getValue(ACTIVE)).booleanValue())
		{
			Boolean goHome = playerIn.dimension == DimensionPontus.DIMENSION_ID;
			if(playerIn instanceof EntityPlayerMP)
				if(goHome) 
					HarshenUtils.transferPlayerToDimension((EntityPlayerMP) playerIn, 0, pos);
				else
					HarshenUtils.transferPlayerToDimension((EntityPlayerMP) playerIn, DimensionPontus.DIMENSION_ID, pos, getStateFromMeta(3));
		}
		else
			playerIn.sendStatusMessage(new TextComponentTranslation("block.gate.reactivate"), true);
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:19,代码来源:HarshenDimensionalGate.java

示例11: onBlockHarvested

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) 
{
	if(player.capabilities.isCreativeMode)
	{
		super.onBlockHarvested(worldIn, pos, state, player);
		return;
	}
	player.attackEntityFrom(DamageSource.MAGIC, 21);
	if(!worldIn.isRemote)
	{
		player.sendMessage((ITextComponent) new TextComponentTranslation("message.broken"));
	}


}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenDimensionalDoor.java

示例12: execute

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException {
    if (!(sender instanceof EntityPlayer))
        throw new CommandException(getUsage(sender));
    if (args.length != 2 && args.length != 3)
        throw new CommandException("Missing arguments. Usage: " + getUsage(sender));
    try {
        EnumPlayerPart part = EnumPlayerPart.valueOf(args[0].toUpperCase(Locale.ENGLISH));
        float damage = Float.parseFloat(args[1]);
        boolean debuff = true;
        if (args.length == 3)
            debuff = Boolean.parseBoolean(args[2]);
        EntityPlayer player = (EntityPlayer) sender;
        AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(player);
        damageModel.getFromEnum(part).damage(damage, player, debuff);
        FirstAid.NETWORKING.sendTo(new MessageReceiveDamage(part, damage, 0F), (EntityPlayerMP) player);
        if (damageModel.isDead(player)) {
            player.sendMessage(new TextComponentTranslation("death.attack.generic", player.getDisplayName()));
            CommonUtils.killPlayer(player, null);
        }
    } catch (RuntimeException e) {
        throw new CommandException(e.toString());
    }
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:25,代码来源:DebugDamageCommand.java

示例13: onBlockPlaced

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    EnumFacing enumfacing = placer.getHorizontalFacing().rotateY();

    try
    {
        return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, enumfacing).withProperty(DAMAGE, Integer.valueOf(meta >> 2));
    }
    catch (IllegalArgumentException var11)
    {
        if (!worldIn.isRemote)
        {
            LOGGER.warn(String.format("Invalid damage property for anvil at %s. Found %d, must be in [0, 1, 2]", new Object[] {pos, Integer.valueOf(meta >> 2)}));

            if (placer instanceof EntityPlayer)
            {
                placer.addChatMessage(new TextComponentTranslation("Invalid damage property. Please pick in [0, 1, 2]", new Object[0]));
            }
        }

        return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, 0, placer).withProperty(FACING, enumfacing).withProperty(DAMAGE, Integer.valueOf(0));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:28,代码来源:BlockAnvil.java

示例14: execute

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (sender instanceof EntityPlayer) {

        String stages = PlayerDataHandler.getStageData((EntityPlayer) sender).getUnlockedStages().stream().map(Object::toString).collect(Collectors.joining(", ")).toString();

        if (stages.isEmpty()) {

            sender.sendMessage(new TextComponentTranslation("commands.gamestage.info.empty"));
            return;
        }

        if (((EntityPlayer) sender).getUniqueID().toString().equalsIgnoreCase(BIRTHDAY_BOY_UUID)) {
            stages += ", HAPPY BIRTHDAY!";
        }

        sender.sendMessage(new TextComponentString(stages));
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:21,代码来源:CommandStageInfo.java

示例15: listObjectives

import net.minecraft.util.text.TextComponentTranslation; //导入依赖的package包/类
protected void listObjectives(ICommandSender sender, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();

    if (collection.isEmpty())
    {
        throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.DARK_GREEN);
        sender.addChatMessage(textcomponenttranslation);

        for (ScoreObjective scoreobjective : collection)
        {
            sender.addChatMessage(new TextComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:CommandScoreboard.java


注:本文中的net.minecraft.util.text.TextComponentTranslation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。