本文整理汇总了Java中net.minecraft.util.text.TextComponentString类的典型用法代码示例。如果您正苦于以下问题:Java TextComponentString类的具体用法?Java TextComponentString怎么用?Java TextComponentString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextComponentString类属于net.minecraft.util.text包,在下文中一共展示了TextComponentString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkLoadVisibleChunks
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
private void checkLoadVisibleChunks(Entity p_checkLoadVisibleChunks_1_, float p_checkLoadVisibleChunks_2_, ICamera p_checkLoadVisibleChunks_3_, boolean p_checkLoadVisibleChunks_4_)
{
if (this.loadVisibleChunks)
{
this.loadVisibleChunks = false;
this.loadAllVisibleChunks(p_checkLoadVisibleChunks_1_, (double)p_checkLoadVisibleChunks_2_, p_checkLoadVisibleChunks_3_, p_checkLoadVisibleChunks_4_);
}
if (Keyboard.isKeyDown(61) && Keyboard.isKeyDown(38))
{
this.loadVisibleChunks = true;
TextComponentString textcomponentstring = new TextComponentString(I18n.format("of.message.loadingVisibleChunks", new Object[0]));
this.mc.ingameGUI.getChatGUI().printChatMessage(textcomponentstring);
Reflector.Minecraft_actionKeyF3.setValue(this.mc, Boolean.TRUE);
}
}
示例2: onBlockActivated
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
if (player.isSneaking()) return false;
else {
if (!world.isRemote) {
TileEntitySecurityStation te = (TileEntitySecurityStation) world.getTileEntity(pos);
if (te != null) {
if (te.isPlayerOnWhiteList(player)) {
player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.SECURITY_STATION_INVENTORY.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} else if (!te.hasValidNetwork()) {
player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "This Security Station is out of order: Its network hasn't been properly configured."), false);
} else if (te.hasPlayerHacked(player)) {
player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "You've already hacked this Security Station!"), false);
} else if (getPlayerHackLevel(player) < te.getSecurityLevel()) {
player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "You can't access or hack this Security Station. To hack it you need at least a Pneumatic Helmet upgraded with " + te.getSecurityLevel() + " Security upgrade(s)."), false);
} else {
player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.HACKING.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
}
return true;
}
}
示例3: onPlayerLogin
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event){
if(DifficultyManager.enabled && ProgressiveDifficulty.oldConfigExists){
TextComponentString linkComponent = new TextComponentString("[Progressive Difficulty Wiki]");
ITextComponent[] chats = new ITextComponent[]{
new TextComponentString("[ProgressiveDifficulty] It looks like you have a version 1.0 " +
"config file. Please check out the Progressive Difficulty Wiki for instructions on how" +
" to migrate to a version 2.0 config file."),
linkComponent
};
ClickEvent goLinkEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,"https://github.com/talandar/ProgressiveDifficulty/wiki/2.0-Transition");
linkComponent.getStyle().setClickEvent(goLinkEvent);
linkComponent.getStyle().setColor(TextFormatting.BLUE);
linkComponent.getStyle().setUnderlined(true);
ChatUtil.sendChat(event.player,chats);
}
}
示例4: execute
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
/**
* Callback for when the command is executed
*/
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if(args.length < 1)
{
sender.addChatMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(commandMap.keySet())));
}
else
{
ICommand cmd = getCommandMap().get(args[0]);
if(cmd == null)
{
throw new CommandException("commands.tree_base.invalid_cmd", args[0]);
}
else if(!cmd.checkPermission(server, sender))
{
throw new CommandException("commands.generic.permission");
}
else
{
cmd.execute(server, sender, shiftArgs(args));
}
}
}
示例5: onBlockActivated
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (Config.getInstance().boringSamples)
{
String resource = Types.Vanilla.byMetadata(state.getBlock().getMetaFromState(state)).getResource();
playerIn.sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
}
else
{
this.dropBlockAsItem(worldIn, pos, state, 0);
}
worldIn.setBlockToAir(pos);
playerIn.swingArm(EnumHand.MAIN_HAND);
return true;
}
示例6: printMessageNaked
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
public static void printMessageNaked(String startWith, String message, Style firstStyle, Style secondStyle) {
if(getLocalPlayer() != null && !Strings.isNullOrEmpty(message)) {
if(message.contains("\n")) {
Scanner scanner = new Scanner(message);
scanner.useDelimiter("\n");
Style s1 = firstStyle;
Style s2 = secondStyle;
while (scanner.hasNext()) {
printMessageNaked(startWith, scanner.next(), s1, s2);
// alternate between colors each newline
Style cpy = s1;
s1 = s2;
s2 = cpy;
}
} else {
TextComponentString string = new TextComponentString(startWith + message.replaceAll("\r", ""));
string.setStyle(firstStyle);
getLocalPlayer().sendMessage(string);
}
}
}
示例7: complete
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
/**
* Called when tab key pressed. If it's the first time we tried to complete this string, we ask the server
* for completions. When the server responds, this method gets called again (via setCompletions).
*/
public void complete()
{
super.complete();
if (this.completions.size() > 1)
{
StringBuilder stringbuilder = new StringBuilder();
for (String s : this.completions)
{
if (stringbuilder.length() > 0)
{
stringbuilder.append(", ");
}
stringbuilder.append(s);
}
this.clientInstance.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(stringbuilder.toString()), 1);
}
}
示例8: join
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
public static ITextComponent join(List<ITextComponent> components)
{
ITextComponent itextcomponent = new TextComponentString("");
for (int i = 0; i < components.size(); ++i)
{
if (i > 0)
{
if (i == components.size() - 1)
{
itextcomponent.appendText(" and ");
}
else if (i > 0)
{
itextcomponent.appendText(", ");
}
}
itextcomponent.appendSibling((ITextComponent)components.get(i));
}
return itextcomponent;
}
示例9: onItemUseFirst
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos,
EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
{
TileEntity te = world.getTileEntity(pos);
if(te instanceof TileEntityInfusionRepair)
{
Stack<RecipeElement> pendingIngredients = ((TileEntityInfusionRepair)te).getPendingIngredients();
if(!pendingIngredients.isEmpty())
{
RecipeElement element = pendingIngredients.peek();
player.sendMessage(new TextComponentString(element.toFriendlyString()));
}
}
return EnumActionResult.SUCCESS;
}
示例10: CommandEvents
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void CommandEvents(CommandEvent evt) {
if(Main.debug==1)System.out.println(evt.getSender().getName() + " called Command " + evt.getSender().toString());
if(evt.getSender() instanceof EntityPlayer){
if(!Main.logged.contains(evt.getSender().getName())){
//System.out.println(evt.getCommand().getCommandName().toString());
if(!evt.getCommand().getCommandName().toString().contains("login") && !evt.getCommand().getCommandName().toString().contains("register")){
evt.setCanceled(true);
if(Main.passwords.containsKey(evt.getSender().getName())){
evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
} else {
evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
}
}
}
}
}
示例11: complete
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
public void complete()
{
super.complete();
if (this.completions.size() > 1)
{
StringBuilder stringbuilder = new StringBuilder();
for (String s : this.completions)
{
if (stringbuilder.length() > 0)
{
stringbuilder.append(", ");
}
stringbuilder.append(s);
}
this.clientInstance.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(stringbuilder.toString()), 1);
}
}
示例12: canAdvance
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null && tile instanceof TileFeroxia) {
TileFeroxia te = (TileFeroxia)tile;
EntityPlayer player = UCUtils.getPlayerFromUUID(te.getOwner().toString());
if (!world.isRemote && player != null && world.getPlayerEntityByUUID(te.getOwner()) != null) {
NBTTagCompound tag = player.getEntityData();
if (!tag.hasKey("hasSacrificed"))
{
player.addChatMessage(new TextComponentString(TextFormatting.RED + "The savage plant whispers: \"The time is right to perform a self sacrifice.\""));
tag.setBoolean("hasSacrificed", false);
return false;
}
if (tag.hasKey("hasSacrificed") && tag.getBoolean("hasSacrificed"))
{
tag.removeTag("hasSacrificed");
world.setBlockState(pos, ((Feroxia)state.getBlock()).withAge(7), 2);
GrowthSteps.generateSteps(player);
return false;
}
}
}
return false;
}
示例13: deserialize
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
public ITextComponent deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
if (p_deserialize_1_.isJsonPrimitive())
{
return new TextComponentString(p_deserialize_1_.getAsString());
}
else if (p_deserialize_1_.isJsonArray())
{
JsonArray jsonarray = p_deserialize_1_.getAsJsonArray();
ITextComponent itextcomponent = null;
for (JsonElement jsonelement : jsonarray)
{
ITextComponent itextcomponent1 = this.deserialize(jsonelement, jsonelement.getClass(), p_deserialize_3_);
if (itextcomponent == null)
{
itextcomponent = itextcomponent1;
}
else
{
itextcomponent.appendSibling(itextcomponent1);
}
}
return itextcomponent;
}
else
{
throw new JsonParseException("Don\'t know how to turn " + p_deserialize_1_ + " into a Component");
}
}
示例14: onItemUse
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(worldIn.isRemote) return EnumActionResult.SUCCESS;
TileEntity te = worldIn.getTileEntity(pos);
if(te != null && te instanceof TileMachineController) {
DynamicMachine dm = ((TileMachineController) te).getBlueprintMachine();
if(dm != null) {
BlockArray pattern = dm.getPattern();
if(pattern != null) {
EnumFacing face = EnumFacing.NORTH;
player.sendMessage(new TextComponentString("Attempting structure matching:"));
player.sendMessage(new TextComponentString("Structure is facing: " + worldIn.getBlockState(pos).getValue(BlockController.FACING).name()));
do {
if(face == worldIn.getBlockState(pos).getValue(BlockController.FACING)) {
BlockPos mismatch = pattern.getRelativeMismatchPosition(worldIn, pos);
if(mismatch != null) {
player.sendMessage(new TextComponentString("Failed at relative position: " + mismatch.toString()));
}
}
face = face.rotateYCCW();
pattern = pattern.rotateYCCW();
} while (face != EnumFacing.NORTH);
}
}
}
return EnumActionResult.SUCCESS;
}
示例15: onSlotHack
import net.minecraft.util.text.TextComponentString; //导入依赖的package包/类
@Override
public void onSlotHack(int slot, boolean nuked) {
ItemStack stack = station.getPrimaryInventory().getStackInSlot(slot);
if (!simulating && !stack.isEmpty() && stack.getItemDamage() == ItemNetworkComponents.NETWORK_IO_PORT) {
FMLClientHandler.instance().getClient().player.closeScreen();
FMLClientHandler.instance().getClient().player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Hacking unsuccessful! The Diagnostic Subroutine traced to your location!"), false);
if (gui instanceof GuiSecurityStationHacking)
((GuiSecurityStationHacking) gui).removeUpdatesOnConnectionHandlers();
}
}