MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / getChatComponent

Method getChatComponent

Minecraft-Utils/1.10/src/Gui2ndChat.java:287–325  ·  view source on GitHub ↗
(int mouseX, int mouseY)

Source from the content-addressed store, hash-verified

285 }
286
287 private ey getChatComponent(int mouseX, int mouseY) {
288 if (!this.isChatOpened()) {
289 return null;
290 } else {
291 bdp scaledResolution = new bdp(((Variables) MinecraftFactory.getVars()).getMinecraft());
292 int resolutionScaleFactor = scaledResolution.e();
293 float chatScale = this.getChatScale();
294 int x = mouseX / resolutionScaleFactor - MinecraftFactory.getVars().getScaledWidth() + getChatWidth();
295 int y = mouseY / resolutionScaleFactor - 40;
296 x = op.d((float) x / chatScale);
297 y = op.d((float) y / chatScale);
298 if (x >= 0 && y >= 0) {
299 int lineCount = Math.min(this.getLineCount(), this.singleChatLines.size());
300 if (x <= op.d((float) this.getChatWidth() / this.getChatScale() + 3 / getChatScale()) && y < MinecraftFactory.getVars().getFontHeight() * lineCount) {
301 int lineId = y / MinecraftFactory.getVars().getFontHeight() + this.scrollPos;
302 if (lineId >= 0 && lineId < this.singleChatLines.size()) {
303 GuiChatLine chatLine = this.singleChatLines.get(lineId);
304 int widthCounter = MinecraftFactory.getClassProxyCallback().is2ndChatTextLeftbound() ? 0 :
305 (int) ((getChatWidth() - MinecraftFactory.getVars().getStringWidth(optStripColor(chatLine.getChatComponent().d())) * chatScale) / chatScale);
306
307 for (ey chatComponent : chatLine.getChatComponent()) {
308 if (chatComponent instanceof fe) { // ChatComponentText
309 widthCounter += MinecraftFactory.getVars().getStringWidth(optStripColor(((fe) chatComponent).g()));
310 if (widthCounter > x) {
311 return chatComponent;
312 }
313 }
314 }
315 }
316
317 return null;
318 } else {
319 return null;
320 }
321 } else {
322 return null;
323 }
324 }
325 }
326
327 private String optStripColor(String text) {
328 return bdt.a(text, false);

Callers 2

drawComponentHoverMethod · 0.95
mouseClickedMethod · 0.95

Calls 15

isChatOpenedMethod · 0.95
getVarsMethod · 0.95
getChatScaleMethod · 0.95
getChatWidthMethod · 0.95
getLineCountMethod · 0.95
getClassProxyCallbackMethod · 0.95
optStripColorMethod · 0.95
getChatComponentMethod · 0.95
sizeMethod · 0.80
gMethod · 0.80
getScaledWidthMethod · 0.65
getFontHeightMethod · 0.65

Tested by

no test coverage detected