Fix coloring across multiple lines
This commit is contained in:
parent
6ce0f40451
commit
c8de4a4e00
@ -20,16 +20,12 @@ package baritone.utils;
|
|||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.gui.GuiNewChat;
|
|
||||||
import net.minecraft.client.gui.GuiUtilRenderComponents;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@ -37,6 +33,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface Helper {
|
public interface Helper {
|
||||||
|
|
||||||
|
ITextComponent MESSAGE_PREFIX = new TextComponentString("§5[§dBaritone§5]§7");
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
default EntityPlayerSP player() {
|
default EntityPlayerSP player() {
|
||||||
@ -73,14 +71,10 @@ public interface Helper {
|
|||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GuiNewChat gui = mc.ingameGUI.getChatGUI();
|
|
||||||
int normalMaxWidth = MathHelper.floor((float) gui.getChatWidth() / gui.getChatScale());
|
|
||||||
int widthWithStyleFormat = normalMaxWidth - 2;
|
|
||||||
List<ITextComponent> list = GuiUtilRenderComponents.splitText(new TextComponentString("§5[§dBaritone§5]§7 " + message), widthWithStyleFormat,
|
|
||||||
this.mc.fontRenderer, false, true);
|
|
||||||
for (ITextComponent component : list) {
|
|
||||||
|
|
||||||
gui.printChatMessage(new TextComponentString("§7" + component.getUnformattedText()));
|
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||||
}
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
|
component.appendSibling(new TextComponentString(" " + message));
|
||||||
|
mc.ingameGUI.getChatGUI().printChatMessage(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user