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

Method getChatComponent

Minecraft-Utils/1.7.10/src/Gui2ndChat.java:418–456  ·  view source on GitHub ↗
(int mouseX, int mouseY)

Source from the content-addressed store, hash-verified

416 }
417
418 private fj getChatComponent(int mouseX, int mouseY) {
419 if (!this.isChatOpened()) {
420 return null;
421 } else {
422 int resolutionScaleFactor = MinecraftFactory.getVars().getScaleFactor();
423 float chatScale = this.getChatScale();
424 int x = mouseX / resolutionScaleFactor - MinecraftFactory.getVars().getScaledWidth() + getChatWidth() + 6;
425 int y = mouseY / resolutionScaleFactor - 27;
426 x = qh.d((float) x / chatScale);
427 y = qh.d((float) y / chatScale);
428 if (x >= 0 && y >= 0) {
429 int lineCount = Math.min(this.getLineCount(), this.singleChatLines.size());
430 if (x <= qh.d((float) this.getChatWidth() / this.getChatScale() + 3 / getChatScale()) && y < MinecraftFactory.getVars().getFontHeight() * lineCount) {
431 int lineId = y / MinecraftFactory.getVars().getFontHeight() + this.scrollPos;
432 if (lineId >= 0 && lineId < this.singleChatLines.size()) {
433 GuiChatLine chatLine = this.singleChatLines.get(lineId);
434 int widthCounter = MinecraftFactory.getClassProxyCallback().is2ndChatTextLeftbound() ? 0 :
435 (int) ((getChatWidth() - MinecraftFactory.getVars().getStringWidth(strip(chatLine.getChatComponent().d(), false)) * chatScale) / chatScale);
436
437 for (Object chatComponentObject : chatLine.getChatComponent()) {
438 fj chatComponent = (fj) chatComponentObject;
439 if (chatComponent instanceof fq) { // ChatComponentText
440 widthCounter += MinecraftFactory.getVars().getStringWidth(strip(((fq) chatComponent).g(), false));
441 if (widthCounter > x) {
442 return chatComponent;
443 }
444 }
445 }
446 }
447
448 return null;
449 } else {
450 return null;
451 }
452 } else {
453 return null;
454 }
455 }
456 }
457
458 public boolean isChatOpened() {
459 return MinecraftFactory.getVars().getMinecraftScreen() instanceof bct;

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
stripMethod · 0.95
getChatComponentMethod · 0.95
sizeMethod · 0.80
gMethod · 0.80
getScaleFactorMethod · 0.65
getScaledWidthMethod · 0.65

Tested by

no test coverage detected