Commit 437267f4 by Jonathan Thomas

Dark transparent background behind chat screen added back for Minecraft 1.20 and 1.20.1.

parent f056dd02
Pipeline #13261 passed with stages
in 2 minutes 13 seconds
......@@ -18,6 +18,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Fixed
- Changing death message timestamp output to use DEBUG log level
- Bug with build causing issues with 1.20, 1.20.1 builds (wrong minimum version set in fabric.mod.json)
- Dark transparent background behind chat screen added back for Minecraft 1.20 and 1.20.1.
## [1.2.1] - 2025-01-01
......
......@@ -2,6 +2,7 @@ package com.owlmaddie.ui;
import com.owlmaddie.chat.ChatDataManager;
import com.owlmaddie.network.ClientPackets;
import com.owlmaddie.utils.VersionUtils;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
......@@ -99,6 +100,11 @@ public class ChatScreen extends Screen {
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// Render custom background only for older versions
if (VersionUtils.isOlderThan("1.20.2")) {
renderBackground(context);
}
// Render the label text above the text field
int labelWidth = textRenderer.getWidth(labelText);
int labelX = (this.width - labelWidth) / 2; // Centered X position
......@@ -116,6 +122,11 @@ public class ChatScreen extends Screen {
super.render(context, mouseX, mouseY, delta);
}
public void renderBackground(DrawContext context) {
// Draw a slightly lighter semi-transparent rectangle as the background
context.fillGradient(0, 0, this.width, this.height, 0xA3000000, 0xA3000000);
}
@Override
public boolean shouldCloseOnEsc() {
// Return true if you want the screen to close when the ESC key is pressed
......
package com.owlmaddie.utils;
import net.minecraft.SharedConstants;
/**
* The {@code VersionUtils} class is used to quickly compare the current version of Minecraft.
*/
public class VersionUtils {
public static boolean isOlderThan(String targetVersion) {
String currentVersion = SharedConstants.getGameVersion().getName();
return currentVersion.compareTo(targetVersion) < 0;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment