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

Method getChatComponent

Minecraft-Utils/1.8.9/src/Gui2ndChat.java:286–324  ·  view source on GitHub ↗
(int mouseX, int mouseY)

Source from the content-addressed store, hash-verified

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