use of net.minecraft.util.text.TextComponentString in project ImmersiveEngineering by BluSunrize.
the class CommandMineral method perform.
@Override
public void perform(CommandHandler handler, MinecraftServer server, ICommandSender sender, String[] args) {
if (args.length > 1) {
DimensionChunkCoords coords = new DimensionChunkCoords(sender.getEntityWorld().provider.getDimension(), (sender.getPosition().getX() >> 4), (sender.getPosition().getZ() >> 4));
switch(args[1]) {
case "list":
String s = "";
int i = 0;
for (MineralMix mm : ExcavatorHandler.mineralList.keySet()) s += ((i++) > 0 ? ", " : "") + mm.name;
sender.addChatMessage(new TextComponentString(s));
break;
case "get":
MineralWorldInfo info = ExcavatorHandler.getMineralWorldInfo(sender.getEntityWorld(), coords.chunkXPos, coords.chunkZPos);
sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + getIdent() + ".get", TextFormatting.GOLD + (info.mineral != null ? info.mineral.name : "null") + TextFormatting.RESET, TextFormatting.GOLD + (info.mineralOverride != null ? info.mineralOverride.name : "null") + TextFormatting.RESET, TextFormatting.GOLD + ("" + info.depletion) + TextFormatting.RESET));
break;
case "set":
info = ExcavatorHandler.getMineralWorldInfo(sender.getEntityWorld(), coords.chunkXPos, coords.chunkZPos);
if (args.length < 3) {
sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + getIdent() + ".set.clear", info.mineralOverride != null ? info.mineralOverride.name : "null"));
info.mineralOverride = null;
return;
}
MineralMix mineral = null;
for (MineralMix mm : ExcavatorHandler.mineralList.keySet()) if (mm.name.equalsIgnoreCase(args[2]))
mineral = mm;
if (mineral == null) {
sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + getIdent() + ".set.invalidMineral", args[2]));
return;
}
info.mineralOverride = mineral;
sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + getIdent() + ".set.sucess", mineral.name));
IESaveData.setDirty(sender.getEntityWorld().provider.getDimension());
break;
case "setDepletion":
info = ExcavatorHandler.getMineralWorldInfo(sender.getEntityWorld(), coords.chunkXPos, coords.chunkZPos);
if (args.length < 3) {
String h = I18n.translateToLocal(getHelp(".setDepletion"));
for (String str : h.split("<br>")) sender.addChatMessage(new TextComponentString(str));
return;
}
int depl = 0;
try {
depl = Integer.parseInt(args[2].trim());
} catch (Exception e) {
sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + getIdent() + ".setDepletion.NFE", args[2].trim()));
return;
}
info.depletion = depl;
sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + getIdent() + ".setDepletion.sucess", (depl < 0 ? I18n.translateToLocal(Lib.CHAT_INFO + "coreDrill.infinite") : Integer.toString(depl))));
IESaveData.setDirty(sender.getEntityWorld().provider.getDimension());
break;
default:
sender.addChatMessage(new TextComponentTranslation(getHelp("")));
break;
}
} else
sender.addChatMessage(new TextComponentTranslation(getHelp("")));
}
use of net.minecraft.util.text.TextComponentString in project RecurrentComplex by Ivorforce.
the class GuiHider method hideGUI.
public static boolean hideGUI() {
if (!canHide())
return false;
Minecraft mc = Minecraft.getMinecraft();
hiddenGUI = mc.currentScreen;
if (hiddenGUI == null)
return false;
mc.displayGuiScreen(null);
ITextComponent reopen = new TextComponentString("/" + RCCommands.reopen.getName());
reopen.getStyle().setColor(TextFormatting.GREEN);
reopen.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.reopen.getName()));
reopen.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcreopen.run")));
mc.player.sendMessage(ServerTranslations.format("commands.rc.didhide", reopen));
return true;
}
use of net.minecraft.util.text.TextComponentString in project SecurityCraft by Geforce132.
the class ForgeEventHandler method onPlayerLoggedIn.
@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
mod_SecurityCraft.instance.createIrcBot(event.player.getName());
String tipKey = getRandomTip();
ITextComponent TextComponentString;
if (tipsWithLink.containsKey(tipKey.split("\\.")[2])) {
TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey) + " ").appendSibling(ForgeHooks.newChatWithLinks(tipsWithLink.get(tipKey.split("\\.")[2])));
} else {
TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey));
}
if (mod_SecurityCraft.configHandler.sayThanksMessage) {
event.player.addChatComponentMessage(TextComponentString);
}
}
use of net.minecraft.util.text.TextComponentString in project AgriCraft by AgriCraft.
the class ItemMagnifyingGlass method onItemUse.
// this is called when you right click with this item in hand
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
List<String> list = new ArrayList<>();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
TileEntity te = world.getTileEntity(pos);
// Add a separator.
list.add("========== " + AgriCore.getTranslator().translate("item.agricraft:magnifying_glass.name") + " ==========");
// Add lighting information.
list.add("Brightness: (" + world.getLightFromNeighbors(pos.up()) + "/15)");
// Add block information.
if (block instanceof IAgriDisplayable) {
((IAgriDisplayable) block).addDisplayInfo(list::add);
}
// Add tile information.
if (te instanceof IAgriDisplayable) {
((IAgriDisplayable) te).addDisplayInfo(list::add);
}
// Display information.
for (String msg : list) {
player.sendMessage(new TextComponentString(msg));
}
}
return EnumActionResult.SUCCESS;
}
use of net.minecraft.util.text.TextComponentString in project AgriCraft by AgriCraft.
the class DebugModeIGrowable method debugActionBlockClicked.
@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return;
}
// Start with the position of the block that was clicked on. '7' is gray. Btw, the chat font is not fixed width. :(
StringBuilder outputRaw = new StringBuilder(String.format("`7%1$4d,%2$4d,%3$4d`r ", pos.getX(), pos.getY(), pos.getZ()));
// Check if the clicked on block has the IGrowable interface.
final IGrowable crop = WorldHelper.getBlock(world, pos, IGrowable.class).orElse(null);
if (crop == null) {
// If it does not, add a nicely formatted report, then skip onward.
outputRaw.append(chatNotIG);
} else {
// Otherwise run the tests and record the results.
IBlockState state = world.getBlockState(pos);
// canGrow
outputRaw.append(crop.canGrow(world, pos, state, false) ? chatTrue : chatFalse);
// canUseBonemeal
outputRaw.append(crop.canUseBonemeal(world, world.rand, pos, state) ? chatTrue : chatFalse);
// grow
crop.grow(world, world.rand, pos, state);
// It's also helpful to also make clear what block was being tested.
// '3' is dark aqua.
outputRaw.append("`3");
outputRaw.append(crop.toString().replaceFirst("Block", ""));
outputRaw.append("`r");
}
// Ellipsis are added as a clue that there's more text.
// '8' is dark gray.
outputRaw.append(" `8[...]`r");
// Create a hover box with explanatory information.
TextComponentString hoverComponent = new TextComponentString(MessageUtil.colorize(chatInfo));
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent);
// Turn the output String into a chat message.
TextComponentString outputComponent = new TextComponentString(MessageUtil.colorize(outputRaw.toString()));
// Add the hover box to the chat message.
outputComponent.getStyle().setHoverEvent(hoverEvent);
// Now send the completed chat message.
player.sendMessage(outputComponent);
}
Aggregations