當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。