Java 类net.minecraft.util.text.Style 实例源码
项目:ForgeHax
文件:Helper.java
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);
}
}
}
项目:CustomWorldGen
文件:EntityPlayerMP.java
public void displayGui(IInteractionObject guiOwner)
{
if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
{
this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
}
else
{
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
this.openContainer = guiOwner.createContainer(this.inventory, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
}
}
项目:Simple-Dimensions
文件:DimensionHandler.java
public void deleteDimension(ICommandSender sender, int dimensionID)
{
if (!dimensionInfo.containsKey(dimensionID))
{
sender.sendMessage(new TextComponentString("The dimension associated with that id is not from the SimpleDimensions mod").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
World worldObj = DimensionManager.getWorld(dimensionID);
if (worldObj.playerEntities.size() > 0)
{
sender.sendMessage(new TextComponentString("Can't delete a dimension with players inside it").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
Entity entitySender = sender.getCommandSenderEntity();
toBeDeleted.put(dimensionID, entitySender != null ? entitySender.getUniqueID() : null);
DimensionManager.unloadWorld(dimensionID);
}
项目:wizards-of-lua
文件:AboutMessage.java
public ITextComponent getTextComponent() {
String message = String.format(
"%s, Version %s - " + "Please note that this is an early Alpha version!"
+ " For sending suggestions and bug reports please visit ",
context.getName(), context.getVersion());
WolAnnouncementMessage result = new WolAnnouncementMessage(message);
result.appendSibling(newChatWithLinks(context.getUrl()));
String recommendedVersion = context.getRecommendedVersion();
if (recommendedVersion != null) {
TextComponentString component =
new TextComponentString("\n New version " + recommendedVersion + " available!");
component.setStyle((new Style()).setColor(TextFormatting.GREEN));
result.appendSibling(component);
}
return result;
}
项目:wizards-of-lua
文件:SpellListAction.java
private ITextComponent format(Iterable<SpellEntity> spells) {
// TODO I18n
WolAnnouncementMessage result = new WolAnnouncementMessage("Active spells:\n");
for (SpellEntity spell : spells) {
TextComponentString name = new TextComponentString(spell.getSid() + ": ");
name.setStyle((new Style()).setColor(TextFormatting.DARK_GREEN));
String description = spell.getProgram().getCode();
if (description.length() > 40) {
description = description.substring(0, 40) + "...";
}
TextComponentString codeMsg = new TextComponentString(description + "\n");
codeMsg.setStyle((new Style()).setColor(TextFormatting.WHITE));
result.appendSibling(name);
result.appendSibling(codeMsg);
}
return result;
}
项目:Gravestone-mod-Extended
文件:SubCommandStatue.java
@Override
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException {
GSLogger.logInfo("Player statue command received");
if (args.length >= 1) {
EnumMemorials memorialType = EnumMemorials.STONE_STEVE_STATUE;
if (StringUtils.isNotBlank(args[2])) {
try {
memorialType = EnumMemorials.getByTypeAndMaterial(EnumMemorialType.STEVE_STATUE, EnumGraveMaterial.valueOf(args[2].toUpperCase()));
} catch (Exception e) {
sender.sendMessage(new TextComponentTranslation("commands.unknown_material").setStyle(new Style().setColor(TextFormatting.RED)));
}
}
GameProfileHelper.dropItem(minecraftServer, sender, args[1], GSBlock.MEMORIAL, memorialType.ordinal());
} else {
sender.sendMessage(new TextComponentTranslation("commands.not_enough_parameters").setStyle(new Style().setColor(TextFormatting.RED)));
}
}
项目:Toms-Mod
文件:BlockMachineBase.java
@Override
public final boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack heldItem = playerIn.getHeldItem(hand);
if (!worldIn.isRemote) {
if (playerIn.isSneaking() && CoreInit.isWrench(playerIn, hand)) {
worldIn.setBlockToAir(pos);
return true;
}
if (heldItem.getItem() instanceof ISwitch && ((ISwitch) heldItem.getItem()).isSwitch(heldItem, playerIn)) {
TileEntityMachineBase te = (TileEntityMachineBase) worldIn.getTileEntity(pos);
if (te.rs == ForceDeviceControlType.SWITCH) {
te.active = !te.active;
return true;
} else {
TomsModUtils.sendNoSpamTranslate(playerIn, new Style().setColor(TextFormatting.RED), "tomsMod.chat.mnotSwitchable", new TextComponentTranslation(heldItem.getUnlocalizedName() + ".name"));
}
}
}
return onBlockActivatedI(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
}
项目:Toms-Mod
文件:ItemMultiTool.java
private void teleportPlayer(EntityPlayer playerIn, BlockPos pos, EnumFacing side, ItemStack stack) {
if (this.getEnergyStored(stack) >= TRANSPORTER_USAGE) {
BlockPos pos2 = pos.offset(side.getOpposite(), side == EnumFacing.UP ? 3 : 2);
IBlockState state = playerIn.world.getBlockState(pos2);
if (state == null || state.getBlock() == null || state.getBlock().isPassable(playerIn.world, pos2)) {
TomsModUtils.sendAccessGrantedMessageToWithExtraInformation(playerIn, stack.getUnlocalizedName() + ".name", "tomsMod.transmissionC");
EntityPlayerMP mp = (EntityPlayerMP) playerIn;
mp.connection.setPlayerLocation(pos2.getX() + 0.5, pos2.getY() + 0.5, pos2.getZ() + 0.5, playerIn.rotationYaw, playerIn.rotationPitch);
if (!playerIn.capabilities.isCreativeMode)
this.extractEnergy(stack, TRANSPORTER_USAGE, false);
} else {
TomsModUtils.sendNoSpamTranslateWithTag(playerIn, new Style().setColor(TextFormatting.RED), stack.getUnlocalizedName() + ".name", "tomsMod.detectedObstacle");
}
} else {
TomsModUtils.sendNoSpamTranslateWithTag(playerIn, new Style().setColor(TextFormatting.RED), stack.getUnlocalizedName() + ".name", "tomsMod.notEnoughPower");
}
}
项目:Toms-Mod
文件:ItemMultiTool.java
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack itemStackIn = playerIn.getHeldItem(hand);
if (playerIn.isSneaking())
itemStackIn.setItemDamage(MultiToolType.get(itemStackIn.getItemDamage() + 1).ordinal());
else {
if (!worldIn.isRemote) {
if (MultiToolType.get(itemStackIn.getItemDamage()) == MultiToolType.ENCODER)
if (hand == EnumHand.MAIN_HAND)
playerIn.openGui(CoreInit.modInstance, GuiIDs.multitoolWriter.ordinal(), worldIn, 0, 0, 0);
else
TomsModUtils.sendNoSpamTranslateWithTag(playerIn, new Style().setColor(TextFormatting.RED), itemStackIn.getUnlocalizedName() + ".name", "tomsMod.invalidHandUseMain");
}
}
// playerIn.posX += 10;
// playerIn.posZ += 10;
return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
项目:Toms-Mod
文件:TileEntityForceConverter.java
public void onBlockActivated(EntityPlayer player, ItemStack held) {
if (!world.isRemote) {
if (held != null && held.getItem() instanceof ISwitch && ((ISwitch) held.getItem()).isSwitch(held, player)) {
if (rsMode == ForceDeviceControlType.SWITCH) {
boolean canAccess = true;
BlockPos securityStationPos = this.getSecurityStationPos();
if (securityStationPos != null) {
TileEntity tileentity = world.getTileEntity(securityStationPos);
if (tileentity instanceof ISecurityStation) {
ISecurityStation tile = (ISecurityStation) tileentity;
canAccess = tile.canPlayerAccess(AccessType.SWITCH_DEVICES, player);
}
}
if (canAccess) {
this.active = !this.active;
} else {
TomsModUtils.sendAccessDeniedMessageTo(player, "tomsMod.chat.fieldSecurity");
}
} else {
TomsModUtils.sendNoSpamTranslate(player, new Style().setColor(TextFormatting.RED), "tomsMod.chat.mnotSwitchable", new TextComponentTranslation(held.getUnlocalizedName() + ".name"));
}
}
}
}
项目:Toms-Mod
文件:ContainerTerminalBase.java
@Override
public Void apply(AutoCraftingHandler.CraftingCalculationResult input) {
if (input.e != null) {
String msg = input.e.getMessage();
currentReport = null;
calculated = true;
dataSent = false;
TomsModUtils.sendNoSpamTranslate(player, new Style().setColor(TextFormatting.RED), "tomsMod.chat.craftFail", new TextComponentTranslation(msg != null ? msg : "tomsMod.na"));
input.e.printStackTrace();
} else {
currentReport = input.c;
calculated = true;
dataSent = false;
}
return null;
}
项目:EnchantmentRevealer
文件:EnchantmentWorker.java
private synchronized void dumpError(String tag) {
state = new State(TextFormatting.RED
+ I18n.format("enchantmentrevealer.error.mainmessage"), NO_STRINGS, NO_INTS,
observations.get(observations.size() - 1));
GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
chat.printChatMessage(new TextComponentTranslation("enchantmentrevealer.error.part1",
new TextComponentTranslation("enchantmentrevealer.error." + tag), "d0sboots",
"gmai", "l.com").setStyle(new Style().setColor(TextFormatting.RED)
.setBold(true)));
chat.printChatMessage(new TextComponentTranslation("enchantmentrevealer.error.part2")
.setStyle(new Style().setColor(TextFormatting.YELLOW)));
for (Observation observation : observations) {
chat.printChatMessage(new TextComponentString(observation.toString())
.setStyle(new Style().setColor(TextFormatting.YELLOW)));
}
observations.clear();
candidatesLength = 0;
thread = null;
shrink();
}
项目:D3Commands
文件:CommandGetUUID.java
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length == 0)
{
sender.addChatMessage(new TextComponentString("All online players:").setStyle(new Style().setColor(TextFormatting.GOLD)));
for (GameProfile gp : server.getPlayerList().getAllProfiles())
{
sender.addChatMessage(new TextComponentString(gp.getName() + " -> " + gp.getId()));
}
}
else
{
sender.addChatMessage(new TextComponentString("All listed players:").setStyle(new Style().setColor(TextFormatting.GOLD)));
for (String name : args)
{
EntityPlayerMP player = server.getPlayerList().getPlayerByUsername(name);
if (player == null) sender.addChatMessage(new TextComponentString("No player with name " + name).setStyle(new Style().setColor(TextFormatting.RED)));
else sender.addChatMessage(new TextComponentString(player.getDisplayNameString() + " -> " + player.getUniqueID()));
}
}
}
项目:MnM-Utils
文件:AbstractChatBuilder.java
@Override
public ITextBuilder format(TextFormatting f) {
checkCreated();
if (f.isColor()) {
current.getStyle().setColor(f);
} else if (f.isFancyStyling()) {
if (f == TextFormatting.BOLD) {
current.getStyle().setBold(true);
} else if (f == TextFormatting.ITALIC) {
current.getStyle().setItalic(true);
} else if (f == TextFormatting.UNDERLINE) {
current.getStyle().setUnderlined(true);
} else if (f == TextFormatting.STRIKETHROUGH) {
current.getStyle().setStrikethrough(true);
} else if (f == TextFormatting.OBFUSCATED) {
current.getStyle().setObfuscated(true);
}
} else if (f == TextFormatting.RESET) {
current.setStyle(new Style());
}
return this;
}
项目:ExpandedRailsMod
文件:EntityPlayerMP.java
public void displayGui(IInteractionObject guiOwner)
{
if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
{
this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
}
else
{
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
this.openContainer = guiOwner.createContainer(this.inventory, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
}
}
项目:TabbyChat-2
文件:AbstractChatBuilder.java
@Override
public ITextBuilder format(TextFormatting f) {
checkCreated();
if (f.isColor()) {
current.getStyle().setColor(f);
} else if (f.isFancyStyling()) {
if (f == TextFormatting.BOLD) {
current.getStyle().setBold(true);
} else if (f == TextFormatting.ITALIC) {
current.getStyle().setItalic(true);
} else if (f == TextFormatting.UNDERLINE) {
current.getStyle().setUnderlined(true);
} else if (f == TextFormatting.STRIKETHROUGH) {
current.getStyle().setStrikethrough(true);
} else if (f == TextFormatting.OBFUSCATED) {
current.getStyle().setObfuscated(true);
}
} else if (f == TextFormatting.RESET) {
current.setStyle(new Style());
}
return this;
}
项目:ClientAPI
文件:ChatBuilder.java
/**
* Appends a string with the specified color(s) and an event
* triggered on text click and on text hover. Only one actual
* color should be specified, any other {@code TextFormatting}
* type should be styling. (Bold, Italic, Underline, Strikethrough,
* and Obfuscated)
*
* @param text The string being appended
* @param clickEvent Click event to be used
* @param hoverEvent Hover event to be used
* @param colors Color formatting
* @return This builder
*/
public final ChatBuilder append(String text, @Nullable ClickEvent clickEvent, @Nullable HoverEvent hoverEvent, TextFormatting... colors) {
TextComponentString component = new TextComponentString(text);
Style style = component.getStyle();
Arrays.stream(colors).forEach(color -> {
switch (color) {
case BOLD: {
style.setBold(true);
break;
}
case ITALIC: {
style.setItalic(true);
break;
}
case UNDERLINE: {
style.setUnderlined(true);
break;
}
case STRIKETHROUGH: {
style.setStrikethrough(true);
break;
}
case OBFUSCATED: {
style.setObfuscated(true);
break;
}
default: {
style.setColor(color);
break;
}
}
});
// noinspection ConstantConditions
style.setClickEvent(clickEvent).setHoverEvent(hoverEvent);
this.component.appendSibling(component);
return this;
}
项目:Scripty
文件:ScriptyNetworkHandler.java
@SideOnly(Side.SERVER)
public static void handleOpenRequest(BlockPos pos, EntityPlayerMP player) {
TileEntity te = player.world.getTileEntity(pos);
if (te instanceof ScriptyBlock.TEScriptyBlock) {
ScriptyBlock.TEScriptyBlock scriptyBlock = (ScriptyBlock.TEScriptyBlock) te;
if (scriptyBlock.getOwner() != null && scriptyBlock.getOwner().isEntityEqual(player)) {
player.sendMessage(new TextComponentString(scriptyBlock.getOwner().getName() + " is already using this Scripty block.").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
scriptyBlock.setOwner(player);
sendContentMessage(player, pos, scriptyBlock.getContent(), scriptyBlock.getLanguage(), scriptyBlock.isParsing());
}
}
项目:ForgeHax
文件:ConsoleIO.java
public static void write(String msg, Style style) {
String tab = Strings.repeat('>', Math.max(getOrCreate().get(), MIN_INDENT)) + " ";
if(style == null)
Helper.printMessageNaked(tab, msg); //TODO: use a non-chat console
else
Helper.printMessageNaked(tab, msg, style); //TODO: use a non-chat console
}
项目:UniversalRemote
文件:TextFormatter.java
public static ITextComponent translateAndStyle(TextFormatting color, boolean italic, String unlocalized)
{
TextComponentTranslation t = new TextComponentTranslation(unlocalized);
Style s = new Style();
s.setColor(color);
s.setItalic(italic);
t.setStyle(s);
return t;
}
项目:UniversalRemote
文件:TextFormatter.java
public static ITextComponent translateAndStyle(TextFormatting color, String unlocalized, Object... args)
{
TextComponentTranslation t = new TextComponentTranslation(unlocalized, args);
Style s = new Style();
s.setColor(color);
t.setStyle(s);
return t;
}
项目:UniversalRemote
文件:TextFormatter.java
public static ITextComponent style(TextFormatting color, boolean italic, String unstyledString)
{
TextComponentString t = new TextComponentString(unstyledString);
Style s = new Style();
s.setColor(color);
s.setItalic(italic);
t.setStyle(s);
return t;
}
项目:UniversalRemote
文件:TextFormatter.java
public static ITextComponent style(TextFormatting color, String unstyledString, Object... args)
{
TextComponentString t = new TextComponentString(String.format(unstyledString, args));
Style s = new Style();
s.setColor(color);
t.setStyle(s);
return t;
}
项目:UniversalRemote
文件:TextFormatter.java
public static ITextComponent addHoverText(ITextComponent component, ITextComponent hoverComponent)
{
Style s = component.getStyle();
s.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent));
component.setStyle(s);
return component;
}
项目:UniversalRemote
文件:TextFormatter.java
public static ITextComponent addURLClick(ITextComponent component, String url)
{
Style s = component.getStyle();
s.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
component.setStyle(s);
return component;
}
项目:Zombe-Modpack
文件:EntityPlayerMP.java
public void displayGui(IInteractionObject guiOwner)
{
if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
{
this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
}
else
{
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
this.openContainer = guiOwner.createContainer(this.inventory, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
}
项目:EMC
文件:ChatProcessor.java
public static ITextComponent getITextComponent(String chatMessage) {
ITextComponent textComponent = new net.minecraft.util.text.TextComponentString("");
String[] messageParts = chatMessage.split(" ");
int pathIndex = 0;
for (String messagePart : messageParts) {
ITextComponent append = new net.minecraft.util.text.TextComponentString(messagePart);
Style chatStyle = new Style();
if (URL_PATTERN.matcher(ChatColor.stripColor(messagePart)).matches()) {
chatStyle.setUnderlined(Boolean.valueOf(true));
chatStyle.setClickEvent(new net.minecraft.util.text.event.ClickEvent(
net.minecraft.util.text.event.ClickEvent.Action.OPEN_URL, ChatColor.stripColor(messagePart)));
}
String currentPath = chatMessage.substring(0, chatMessage.indexOf(messagePart, pathIndex));
String lastColor = ChatColor.getLastColors(currentPath);
if (lastColor.length() >= 2) {
char formattingChar = lastColor.charAt(1);
formatChatStyle(chatStyle, formattingChar);
}
append.setStyle(chatStyle);
textComponent.appendSibling(append);
textComponent.appendText(" ");
pathIndex += messagePart.length() - 1;
}
return textComponent;
}
项目:EMC
文件:ChatProcessor.java
public static void printChatMessage(String chatMessage) {
ITextComponent textComponent = new net.minecraft.util.text.TextComponentString("");
String[] messageParts = chatMessage.split(" ");
int pathIndex = 0;
for (String messagePart : messageParts) {
ITextComponent append = new net.minecraft.util.text.TextComponentString(messagePart);
Style chatStyle = new Style();
if (URL_PATTERN.matcher(ChatColor.stripColor(messagePart)).matches()) {
chatStyle.setUnderlined(Boolean.valueOf(true));
chatStyle.setClickEvent(new net.minecraft.util.text.event.ClickEvent(
net.minecraft.util.text.event.ClickEvent.Action.OPEN_URL, ChatColor.stripColor(messagePart)));
}
String currentPath = chatMessage.substring(0, chatMessage.indexOf(messagePart, pathIndex));
String lastColor = ChatColor.getLastColors(currentPath);
if (lastColor.length() >= 2) {
char formattingChar = lastColor.charAt(1);
formatChatStyle(chatStyle, formattingChar);
}
append.setStyle(chatStyle);
textComponent.appendSibling(append);
textComponent.appendText(" ");
pathIndex += messagePart.length() - 1;
}
Minecraft.getMinecraft().ingameGUI.getChatGUI().setChatLine(textComponent, 0,
Minecraft.getMinecraft().ingameGUI.getUpdateCounter(), false);
}
项目:EMC
文件:ChatProcessor.java
private static Style formatChatStyle(Style chatStyle, char formattingChar) {
switch (formattingChar) {
case 'k':
chatStyle.setObfuscated(Boolean.valueOf(true));
break;
case 'm':
chatStyle.setStrikethrough(Boolean.valueOf(true));
break;
case 'l':
chatStyle.setBold(Boolean.valueOf(true));
break;
case 'n':
chatStyle.setUnderlined(Boolean.valueOf(true));
break;
case 'o':
chatStyle.setItalic(Boolean.valueOf(true));
break;
case 'r':
chatStyle.setObfuscated(Boolean.valueOf(false));
chatStyle.setStrikethrough(Boolean.valueOf(false));
chatStyle.setBold(Boolean.valueOf(false));
chatStyle.setUnderlined(Boolean.valueOf(false));
chatStyle.setItalic(Boolean.valueOf(false));
chatStyle.setColor(TextFormatting.RESET);
break;
case 'p':
case 'q':
default:
chatStyle.setColor(getTextFormattingByValue(formattingChar));
}
return chatStyle;
}
项目:Backmemed
文件:EntityPlayerMP.java
public void displayGui(IInteractionObject guiOwner)
{
if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
{
this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
}
else
{
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
this.openContainer = guiOwner.createContainer(this.inventory, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
}
项目:LittleThings-old
文件:DeprecatedWarning.java
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent e)
{
if (Minecraft.getMinecraft().thePlayer != null && e.phase == TickEvent.Phase.END && !warnedPlayer && modHasDeprecatedClasses) {
Style s = new Style().setColor(TextFormatting.RED);
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
player.addChatMessage(new TextComponentString(LibMisc.MOD_NAME + " has deprecated blocks! ").setChatStyle(s));
player.addChatMessage(new TextComponentString("The following need to be replaced before the next update: ").setChatStyle(s));
for (String str : deprecatedAreas)
player.addChatMessage(new TextComponentString("- " + str).setChatStyle(s));
warnedPlayer = true;
}
}
项目:LittleThings-old
文件:CommandHead.java
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(sender);
ItemStack stack = entityPlayerMP.getHeldItem(EnumHand.MAIN_HAND);
entityPlayerMP.inventoryContainer.detectAndSendChanges();
entityPlayerMP.replaceItemInInventory(100 + EntityEquipmentSlot.HEAD.getIndex(), stack);
if (!entityPlayerMP.isCreative()) {
entityPlayerMP.setHeldItem(EnumHand.MAIN_HAND, null);
}
sender.addChatMessage(new TextComponentString("Success").setChatStyle(new Style().setColor(TextFormatting.GREEN)));
entityPlayerMP.inventoryContainer.detectAndSendChanges();
}
项目:Snitch-Master
文件:QuietTimeHandler.java
private ITextComponent parseHover(SnitchAlert alert)
{
try
{
//If we are parsing a hover then the current index is for the hover instruction
//That means that we have 2 parts: 1-TEXT YOU SEE IN CHAT, 2-TEXT THAT YOU SEE WHEN YOU HOVER
//Either of those 2 could be a string substitution or a variable instruction
String text;
//Move index to the first instruction part (text to show in chat)
index++;
String showText = getTextForCurrentInstruction(alert);
//Move index to second instruction part (text shown on hover)
index++;
String hoverText = getTextForCurrentInstruction(alert);
index++;
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText));
ITextComponent hoverComponent = new TextComponentString(showText).setStyle(new Style().setColor(TextFormatting.AQUA).setHoverEvent(hoverEvent));
index--;//????
return hoverComponent;
}
catch (Exception e)
{
return null;
}
}
项目:wizards-of-lua
文件:LuaCommand.java
private void handleException(Exception ex, ICommandSender sender) {
String message = String.format("An unexpected error occured during lua command execution: %s",
ex.getMessage());
wol.logger.error(message, ex);
String stackTrace = getStackTrace(ex);
WolAnnouncementMessage txt = new WolAnnouncementMessage(message);
TextComponentString details = new TextComponentString(stackTrace);
txt.setStyle((new Style()).setColor(TextFormatting.RED).setBold(Boolean.valueOf(true)));
txt.appendSibling(details);
sender.sendMessage(txt);
}
项目:wizards-of-lua
文件:SpellEntity.java
private void handleException(SpellException e) {
e.printStackTrace();
String message = String.format("Error during command execution: %s", e.getMessage());
TextComponentString txt = new TextComponentString(message);
txt.setStyle((new Style()).setColor(TextFormatting.RED).setBold(Boolean.valueOf(true)));
owner.sendMessage(txt);
}
项目:wizards-of-lua
文件:WolAnnouncementMessage.java
public WolAnnouncementMessage(String message) {
super("chat.type.announcement", new Object[] {"WoL"});
ITextComponent details = new TextComponentString(message);
details.setStyle((new Style()).setColor(TextFormatting.WHITE));
this.appendSibling(details);
setStyle((new Style()).setColor(TextFormatting.GOLD));
}
项目:wizards-of-lua
文件:TestEnvMessage.java
public TestEnvMessage(String message) {
super("chat.type.announcement", new Object[] {"WoL-TestEnv"});
ITextComponent details = new TextComponentString(message);
details.setStyle((new Style()).setColor(TextFormatting.WHITE));
this.appendSibling(details);
setStyle((new Style()).setColor(TextFormatting.GOLD));
}
项目:Gravestone-mod-Extended
文件:SubCommandCorpses.java
@Override
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException {
GSLogger.logInfo("Corpse generation command received");
if (args.length >= 1) {
GameProfileHelper.dropItem(minecraftServer, sender, args[1], GSBlock.CORPSE, EnumCorpse.STEVE.ordinal());
} else {
sender.sendMessage(new TextComponentTranslation("commands.not_enough_parameters").setStyle(new Style().setColor(TextFormatting.RED)));
}
}
项目:malmo
文件:AgentQuitFromTimeUpImplementation.java
@Override
protected void drawCountDown(int secondsRemaining)
{
TextComponentString text = new TextComponentString("" + secondsRemaining + "...");
Style style = new Style();
style.setBold(true);
if (secondsRemaining <= 5)
style.setColor(TextFormatting.RED);
text.setStyle(style);
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, 1);
}
项目:MC-Prefab
文件:ItemInstantBridge.java
private boolean BuildBridge(World worldIn, EntityPlayer playerIn, BlockPos originalBlockPos)
{
EnumFacing playerFacing = playerIn.getHorizontalFacing();
BlockPos startingPos = originalBlockPos.offset(playerFacing.rotateYCCW(), 2);
BlockPos endPos = originalBlockPos.offset(playerFacing, 50).offset(playerFacing.rotateY(), 2).up(2);
if (!BuildingMethods.CheckBuildSpaceForAllowedBlockReplacement(null, worldIn, startingPos, endPos, playerIn))
{
playerIn.sendMessage(new TextComponentTranslation(GuiLangKeys.GUI_STRUCTURE_NOBUILD).setStyle(new Style().setColor(TextFormatting.GREEN)));
return false;
}
for (int i = 0; i < 50; i++)
{
BlockPos currentPos = originalBlockPos.offset(playerFacing, i).up();
// Place the floor
BuildingMethods.ReplaceBlock(worldIn, currentPos, Blocks.COBBLESTONE);
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateYCCW()), Blocks.COBBLESTONE);
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateYCCW(), 2), Blocks.COBBLESTONE);
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateY()), Blocks.COBBLESTONE);
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateY(), 2), Blocks.COBBLESTONE);
// Build the walls.
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateYCCW(), 2).up(), Blocks.COBBLESTONE_WALL);
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateY(), 2).up(), Blocks.COBBLESTONE_WALL);
if (i % 6 == 0)
{
// Place torches.
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateYCCW(), 2).up(2), Blocks.TORCH);
BuildingMethods.ReplaceBlock(worldIn, currentPos.offset(playerFacing.rotateY(), 2).up(2), Blocks.TORCH);
}
}
return true;
}