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

Method getChatComponent

Minecraft-Utils/1.13/src/Gui2ndChat.java:276–313  ·  view source on GitHub ↗
(int mouseX, int mouseY)

Source from the content-addressed store, hash-verified

274 }
275
276 private ij getChatComponent(int mouseX, int mouseY) {
277 if (!this.isChatOpened()) {
278 return null;
279 } else {
280 int resolutionScaleFactor = MinecraftFactory.getVars().getScaleFactor();
281 float chatScale = this.getChatScale();
282 int x = mouseX / resolutionScaleFactor - MinecraftFactory.getVars().getScaledWidth() + getChatWidth();
283 int y = mouseY / resolutionScaleFactor - 40;
284 x = xp.d((float) x / chatScale);
285 y = xp.d((float) y / chatScale);
286 if (x >= 0 && y >= 0) {
287 int lineCount = Math.min(this.getLineCount(), this.singleChatLines.size());
288 if (x <= xp.d((float) this.getChatWidth() / this.getChatScale() + 3 / getChatScale()) && y < MinecraftFactory.getVars().getFontHeight() * lineCount) {
289 int lineId = y / MinecraftFactory.getVars().getFontHeight() + this.scrollPos;
290 if (lineId >= 0 && lineId < this.singleChatLines.size()) {
291 GuiChatLine chatLine = this.singleChatLines.get(lineId);
292 int widthCounter = MinecraftFactory.getClassProxyCallback().is2ndChatTextLeftbound() ? 0 :
293 (int) ((getChatWidth() - MinecraftFactory.getVars().getStringWidth(optStripColor(chatLine.getChatComponent().getString())) * chatScale) / chatScale);
294
295 for (ij chatComponent : chatLine.getChatComponent()) {
296 if (chatComponent instanceof iq) { // ChatComponentText
297 widthCounter += MinecraftFactory.getVars().getStringWidth(optStripColor(((iq) chatComponent).f()));
298 if (widthCounter > x) {
299 return chatComponent;
300 }
301 }
302 }
303 }
304
305 return null;
306 } else {
307 return null;
308 }
309 } else {
310 return null;
311 }
312 }
313 }
314
315 private String optStripColor(String text) {
316 return cgl.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
getScaleFactorMethod · 0.65
getScaledWidthMethod · 0.65
getFontHeightMethod · 0.65

Tested by

no test coverage detected