use of net.minecraft.util.text.ITextComponent in project RFTools by McJty.
the class CmdSetStyle method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length > 2) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
if (!(sender instanceof EntityPlayer)) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "This command only works as a player!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
EntityPlayer player = (EntityPlayer) sender;
PreferencesProperties properties = McJtyLib.getPreferencesProperties(player);
if (args.length < 2) {
GuiStyle style = properties.getStyle();
ITextComponent component = new TextComponentString(TextFormatting.YELLOW + "Current GUI style: " + style.getStyle());
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
String s = fetchString(sender, args, 1, "");
boolean b = properties.setStyle(s);
if (!b) {
String buf = "";
for (GuiStyle style : GuiStyle.values()) {
buf = buf + " " + style.getStyle();
}
ITextComponent component = new TextComponentString(TextFormatting.RED + "Unknown style! Options:" + buf);
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
}
}
use of net.minecraft.util.text.ITextComponent in project RFTools by McJty.
the class CmdTeleport method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 5) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Several parameters are missing!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
} else if (args.length > 5) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
int dim = fetchInt(sender, args, 1, 0);
int x = fetchInt(sender, args, 2, 0);
int y = fetchInt(sender, args, 3, 100);
int z = fetchInt(sender, args, 4, 0);
if (sender instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) sender;
int currentId = player.getEntityWorld().provider.getDimension();
if (currentId != dim) {
mcjty.lib.varia.TeleportationTools.teleportToDimension(player, dim, x, y, z);
} else {
player.setPositionAndUpdate(x, y, z);
}
}
}
use of net.minecraft.util.text.ITextComponent in project RFTools by McJty.
the class PorterTools method checkTarget.
private static int checkTarget(EntityPlayer playerEntity, NBTTagCompound tagCompound, TeleportDestinations destinations, int curtarget, int donext, int tgt) {
if (tagCompound.hasKey("target" + tgt)) {
int target = tagCompound.getInteger("target" + tgt);
GlobalCoordinate gc = destinations.getCoordinateForId(target);
if (gc != null) {
TeleportDestination destination = destinations.getDestination(gc);
if (destination != null) {
if (donext == 1) {
String name = destination.getName() + " (dimension " + destination.getDimension() + ")";
tagCompound.setInteger("target", target);
ITextComponent component = new TextComponentString(TextFormatting.GREEN + "Target: " + TextFormatting.WHITE + name);
if (playerEntity != null) {
playerEntity.sendStatusMessage(component, false);
}
donext = 2;
} else if (target == curtarget) {
donext = 1;
}
}
}
}
return donext;
}
use of net.minecraft.util.text.ITextComponent in project minecolonies by Minecolonies.
the class WindowTownHall method teleportToColony.
/**
* On Button click teleport to the colony..
*
* @param button the clicked button.
*/
private void teleportToColony(@NotNull final Button button) {
final int row = alliesList.getListElementIndexByPane(button);
final ColonyView ally = allies.get(row);
final ITextComponent teleport = new TextComponentString(LanguageHandler.format(DO_REALLY_WANNA_TP, ally.getName())).setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, TELEPORT_COMMAND + ally.getID())));
Minecraft.getMinecraft().player.sendMessage(teleport);
}
use of net.minecraft.util.text.ITextComponent in project minecolonies by Minecolonies.
the class TileEntityInfoPosterRenderer method renderText.
private void renderText(final IBlockState actualState, final double addZ, final double addX, final TileEntityInfoPoster te, final double x, final double y, final double z) {
GlStateManager.pushMatrix();
final FontRenderer fontrenderer = this.getFontRenderer();
double plusX = addX;
double plusZ = addZ;
int facing = (int) actualState.getValue(BlockWallSign.FACING).getHorizontalAngle();
switch(facing) {
case NINETY_DEGREE:
facing = THREE_QUARTERS;
plusZ -= BLOCK_MIDDLE;
plusX -= SLIGHTLY_IN_FRONT;
break;
case HALF_ROTATION:
plusX += BLOCK_MIDDLE;
plusZ -= SLIGHTLY_IN_FRONT;
break;
case THREE_QUARTERS:
facing = NINETY_DEGREE;
plusZ += BLOCK_MIDDLE;
plusX += SLIGHTLY_IN_FRONT;
break;
default:
plusX -= BLOCK_MIDDLE;
plusZ += SLIGHTLY_IN_FRONT;
break;
}
GlStateManager.translate(x + plusX, y + YOFFSET * 2, z + plusZ);
GlStateManager.rotate(facing, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(SCALING_FACTOR, -SCALING_FACTOR, SCALING_FACTOR);
GlStateManager.depthMask(false);
for (int j = 0; j < te.signText.length; ++j) {
if (te.signText[j] != null) {
final List<ITextComponent> list = GuiUtilRenderComponents.splitText(te.signText[j], MAX_TEXT_LENGTH, fontrenderer, false, true);
final String text = list != null && !list.isEmpty() ? list.get(0).getFormattedText() : "";
fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, j * TEXT_OFFSET_X - te.signText.length * TEXT_OFFSET_Y, 0);
}
}
GlStateManager.depthMask(true);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
Aggregations