Java Code Examples for com.mojang.realmsclient.gui.ChatFormatting#GRAY

The following examples show how to use com.mojang.realmsclient.gui.ChatFormatting#GRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PortalFinderModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
private void printPortalToChat(Vec3d portal) {
    final TextComponentString portalTextComponent = new TextComponentString("Portal found!");

    String overworld = "";
    String nether = "";

    if (Minecraft.getMinecraft().player.dimension == 0) { // overworld
        overworld = String.format("Overworld: X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z);
        nether = String.format("Nether: X: %s, Y: %s, Z: %s", (int) portal.x / 8, (int) portal.y, (int) portal.z / 8);
    } else if (Minecraft.getMinecraft().player.dimension == -1) { // nether
        overworld = String.format("Overworld: X: %s, Y: %s, Z: %s", (int) portal.x * 8, (int) portal.y, (int) portal.z * 8);
        nether = String.format("Nether: X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z);
    }

    int playerDistance = (int) Minecraft.getMinecraft().player.getDistance(portal.x, portal.y, portal.z);
    String distance = ChatFormatting.GRAY + "" + playerDistance + "m away";

    String hoverText = overworld + "\n" + nether + "\n" + distance;
    portalTextComponent.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText))));

    Seppuku.INSTANCE.logcChat(portalTextComponent);
}
 
Example 2
Source File: CoordsComponent.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
    super.render(mouseX, mouseY, partialTicks);
    final DecimalFormat df = new DecimalFormat("#.#");

    final String coords = ChatFormatting.GRAY + "x " + ChatFormatting.RESET +
            df.format(Minecraft.getMinecraft().player.posX) + ChatFormatting.RESET + "," +
            ChatFormatting.GRAY + " y " + ChatFormatting.RESET + df.format(Minecraft.getMinecraft().player.posY) + ChatFormatting.RESET + "," +
            ChatFormatting.GRAY + " z " + ChatFormatting.RESET + df.format(Minecraft.getMinecraft().player.posZ) + ChatFormatting.RESET;

    this.setW(Minecraft.getMinecraft().fontRenderer.getStringWidth(coords));
    this.setH(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT);

    //RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xAA202020);
    Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(coords, this.getX(), this.getY(), -1);
}
 
Example 3
Source File: NetherCoordsComponent.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
    super.render(mouseX, mouseY, partialTicks);
    final DecimalFormat df = new DecimalFormat("#.#");

    final String coords = ChatFormatting.GRAY + "x " + ChatFormatting.RED +
            df.format(Minecraft.getMinecraft().player.posX * 8) + ChatFormatting.RED + "," +
            ChatFormatting.GRAY + " y " + ChatFormatting.RED + df.format(Minecraft.getMinecraft().player.posY) + ChatFormatting.RED + "," +
            ChatFormatting.GRAY + " z " + ChatFormatting.RED + df.format(Minecraft.getMinecraft().player.posZ * 8) + ChatFormatting.RESET;

    final String nether = ChatFormatting.GRAY + "x " + ChatFormatting.RED +
            df.format(Minecraft.getMinecraft().player.posX / 8) + ChatFormatting.RED + "," +
            ChatFormatting.GRAY + " y " + ChatFormatting.RED + df.format(Minecraft.getMinecraft().player.posY) + ChatFormatting.RED + "," +
            ChatFormatting.GRAY + " z " + ChatFormatting.RED + df.format(Minecraft.getMinecraft().player.posZ / 8) + ChatFormatting.RESET;

    this.setW(Minecraft.getMinecraft().fontRenderer.getStringWidth(Minecraft.getMinecraft().player.dimension == -1 ? coords : nether));
    this.setH(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT);

    //RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x90222222);
    Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(Minecraft.getMinecraft().player.dimension == -1 ? coords : nether, this.getX(), this.getY(), -1);
}
 
Example 4
Source File: RadarHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
public RadarHack()
{
	super("Radar",
		"Shows the location of nearby entities.\n" + ChatFormatting.RED
			+ "red" + ChatFormatting.RESET + " - players\n"
			+ ChatFormatting.GOLD + "orange" + ChatFormatting.RESET
			+ " - monsters\n" + ChatFormatting.GREEN + "green"
			+ ChatFormatting.RESET + " - animals\n" + ChatFormatting.GRAY
			+ "gray" + ChatFormatting.RESET + " - others\n");
	setCategory(Category.RENDER);
	addSetting(radius);
	addSetting(rotate);
	addSetting(filterPlayers);
	addSetting(filterSleeping);
	addSetting(filterMonsters);
	addSetting(filterAnimals);
	addSetting(filterInvisible);
	
	window = new Window("Radar");
	window.setPinned(true);
	window.setInvisible(true);
	window.add(new Radar(this));
}
 
Example 5
Source File: PortalFinderModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private void printEndPortalToChat(Vec3d portal) {
    final TextComponentString portalTextComponent = new TextComponentString("End Portal found!");

    String coords = String.format("X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z);
    int playerDistance = (int) Minecraft.getMinecraft().player.getDistance(portal.x, portal.y, portal.z);
    String distance = ChatFormatting.GRAY + "" + playerDistance + "m away";

    String hoverText = coords + "\n" + distance;
    portalTextComponent.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText))));

    Seppuku.INSTANCE.logcChat(portalTextComponent);
}
 
Example 6
Source File: CalcStrongholdCommand.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (this.firstStart != null && this.firstEnd != null && this.secondStart != null && this.secondEnd != null) {
            final double[] start = new double[]{this.secondStart.x, this.secondStart.z, this.secondEnd.x, this.secondEnd.z};
            final double[] end = new double[]{this.firstStart.x, this.firstStart.z, this.firstEnd.x, this.firstEnd.z};
            final double[] intersection = MathUtil.calcIntersection(start, end);

            if (Double.isNaN(intersection[0]) || Double.isNaN(intersection[1]) || Double.isInfinite(intersection[0]) || Double.isInfinite(intersection[1])) {
                Seppuku.INSTANCE.errorChat("Error lines are parallel");
                Seppuku.INSTANCE.getEventManager().removeEventListener(this);
                return;
            }

            final double dist = Minecraft.getMinecraft().player.getDistance(intersection[0], Minecraft.getMinecraft().player.posY, intersection[1]);

            final TextComponentString component = new TextComponentString("Stronghold found " + ChatFormatting.GRAY + (int) dist + "m away");
            final String coords = String.format("X: %s, Y: ?, Z: %s\nClick to add a Waypoint", (int) intersection[0], (int) intersection[1]);
            final CommandsModule cmds = (CommandsModule) Seppuku.INSTANCE.getModuleManager().find(CommandsModule.class);

            if (cmds != null) {
                component.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(coords))).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmds.prefix.getValue() + "Waypoints add Stronghold " + intersection[0] + " " + Minecraft.getMinecraft().player.posY + " " + intersection[1])));
            }

            Seppuku.INSTANCE.logcChat(component);
            Seppuku.INSTANCE.getNotificationManager().addNotification("", "Stronghold found " + ChatFormatting.GRAY + (int) dist + "m away");
            this.firstStart = null;
            this.firstEnd = null;
            this.secondStart = null;
            this.secondEnd = null;
            Seppuku.INSTANCE.getEventManager().removeEventListener(this);
        }
    }
}
 
Example 7
Source File: PotionEffectsComponent.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
    super.render(mouseX, mouseY, partialTicks);

    final List<PotionEffect> effects =
            new ArrayList<>(Minecraft.getMinecraft().player.getActivePotionEffects());

    final Comparator<PotionEffect> comparator = (first, second) -> {
        final String firstEffect = PotionUtil.getFriendlyPotionName(first) + " " + ChatFormatting.GRAY + Potion.getPotionDurationString(first, 1.0F);
        final String secondEffect = PotionUtil.getFriendlyPotionName(second) + " " + ChatFormatting.GRAY + Potion.getPotionDurationString(second, 1.0F);
        final float dif = Minecraft.getMinecraft().fontRenderer.getStringWidth(secondEffect) - Minecraft.getMinecraft().fontRenderer.getStringWidth(firstEffect);
        return dif != 0 ? (int) dif : secondEffect.compareTo(firstEffect);
    };

    effects.sort(comparator);

    float xOffset = 0;
    float yOffset = 0;
    float maxWidth = 0;

    for (PotionEffect potionEffect : effects) {
        if (potionEffect != null) {
            final String effect = PotionUtil.getFriendlyPotionName(potionEffect) + " " + ChatFormatting.GRAY + Potion.getPotionDurationString(potionEffect, 1.0F);

            final float width = Minecraft.getMinecraft().fontRenderer.getStringWidth(effect);

            if (width >= maxWidth) {
                maxWidth = width;
            }

            if (this.getAnchorPoint() != null) {
                switch (this.getAnchorPoint().getPoint()) {
                    case TOP_CENTER:
                        xOffset = (this.getW() - Minecraft.getMinecraft().fontRenderer.getStringWidth(effect)) / 2;
                        break;
                    case TOP_LEFT:
                    case BOTTOM_LEFT:
                        xOffset = 0;
                        break;
                    case TOP_RIGHT:
                    case BOTTOM_RIGHT:
                        xOffset = this.getW() - Minecraft.getMinecraft().fontRenderer.getStringWidth(effect);
                        break;
                }
            }

            if (this.getAnchorPoint() != null) {
                switch (this.getAnchorPoint().getPoint()) {
                    case TOP_CENTER:
                    case TOP_LEFT:
                    case TOP_RIGHT:
                        Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(effect, this.getX() + xOffset, this.getY() + yOffset, potionEffect.getPotion().getLiquidColor());
                        yOffset += (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT + 1);
                        break;
                    case BOTTOM_LEFT:
                    case BOTTOM_RIGHT:
                        Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(effect, this.getX() + xOffset, this.getY() + (this.getH() - Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT) + yOffset, potionEffect.getPotion().getLiquidColor());
                        yOffset -= (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT + 1);
                        break;
                }
            } else {
                Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(effect, this.getX() + xOffset, this.getY() + yOffset, potionEffect.getPotion().getLiquidColor());
                yOffset += (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT + 1);
            }
        }
    }

    this.setW(maxWidth);
    this.setH(Math.abs(yOffset));
}