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

Method getChatComponent

Minecraft-Utils/1.10.2/src/Gui2ndChat.java:280–318  ·  view source on GitHub ↗
(int mouseX, int mouseY)

Source from the content-addressed store, hash-verified

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