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

Method getChatComponent

Minecraft-Utils/1.12.2/src/Gui2ndChat.java:277–315  ·  view source on GitHub ↗
(int mouseX, int mouseY)

Source from the content-addressed store, hash-verified

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