Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 1.20 #39

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if (file("extra.properties").exists()) {

repositories {
mavenCentral()
mavenLocal() // only used to build the mod locally
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove when not building locally

maven { url 'https://masa.dy.fi/maven' }
maven { url 'https://jitpack.io' }
}
Expand All @@ -29,8 +30,10 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation "fi.dy.masa.malilib:malilib-fabric-1.19.4:${project.malilib_version}"
modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}"
modImplementation "fi.dy.masa.malilib:malilib-fabric-1.20.2:${project.malilib_version}"
//modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}"
modImplementation "io.github.darkkronicle:AdvancedChatCore:1.20.4-1.5.10" // only used to build the mod locally

}

processResources {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.11
fabric_api_version=0.76.0+1.19.4
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
fabric_api_version=0.92.0+1.20.4

mod_version=1.3.8
maven_group=io.github.darkkronicle
archives_base_name=AdvancedChatHUD

malilib_version = 0.15.2
malilib_version = 0.17.0
org.gradle.jvmargs=-Xmx1G
advancedchat_version=v1.5.10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public boolean onKeyTyped(int keyCode, int scanCode, int modifiers) {
}

if (keyCode == KeyCodes.KEY_ESCAPE
&& this.parentScreen != GuiUtils.getCurrentScreen()) {
&& this.getParent() != GuiUtils.getCurrentScreen()) {
// Make sure to save
closeGui(true);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public boolean onKeyTyped(int keyCode, int scanCode, int modifiers) {
}

if (keyCode == KeyCodes.KEY_ESCAPE
&& this.parentScreen != GuiUtils.getCurrentScreen()) {
&& this.getParent() != GuiUtils.getCurrentScreen()) {
// Make sure to save
closeGui(true);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;

@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -95,7 +96,7 @@ public List<TextFieldWrapper<GuiTextFieldGeneric>> getTextFields() {
}

@Override
public void renderEntry(int mouseX, int mouseY, boolean selected, MatrixStack matrixStack) {}
public void renderEntry(int mouseX, int mouseY, boolean selected, DrawContext context) {}

@Override
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
Expand Down Expand Up @@ -208,20 +208,20 @@ public void updateScroll() {
}

public static void drawRect(
MatrixStack stack, int x, int y, int width, int height, int color) {
DrawableHelper.fill(stack, x, y, x + width, y + height, color);
DrawContext context, int x, int y, int width, int height, int color) {
context.fill(x, y, x + width, y + height, color);
}

public static void fill(MatrixStack stack, int x, int y, int x2, int y2, int color) {
DrawableHelper.fill(stack, x, y, x2, y2, color);
public static void fill(DrawContext context, int x, int y, int x2, int y2, int color) {
context.fill(x, y, x2, y2, color);
}

private static void drawOutline(
MatrixStack stack, int x, int y, int width, int height, int color) {
drawRect(stack, x, y, 1, height, color);
drawRect(stack, x + width - 1, y, 1, height, color);
drawRect(stack, x + 1, y, width - 2, 1, color);
drawRect(stack, x + 1, y + height - 1, width - 2, 1, color);
DrawContext context, int x, int y, int width, int height, int color) {
drawRect(context, x, y, 1, height, color);
drawRect(context, x + width - 1, y, 1, height, color);
drawRect(context, x + 1, y, width - 2, 1, color);
drawRect(context, x + 1, y + height - 1, width - 2, 1, color);
}

public void resetScroll() {
Expand Down Expand Up @@ -303,7 +303,7 @@ public int getTotalHeight() {
return getTotalLines() * HudConfigStorage.General.LINE_SPACE.config.getIntegerValue() + (lines.size() - 1) * HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue();
}

public void render(MatrixStack matrixStack, int ticks, boolean focused) {
public void render(DrawContext context, int ticks, boolean focused) {
if (!focused) {
resetScroll();
}
Expand All @@ -321,8 +321,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
scrolledHeight = totalHeight;
}

matrixStack.push();
matrixStack.scale((float) getScale(), (float) getScale(), 1);
context.getMatrices().push();
context.getMatrices().scale((float) getScale(), (float) getScale(), 1);

int lines = 0;
int currentHeight = 0;
Expand Down Expand Up @@ -369,7 +369,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
}
ChatMessage.AdvancedChatLine line = message.getLines().get(renderTopFirst ? message.getLineCount() - i - 1 : i);
drawLine(
matrixStack,
context,
line,
leftX,
renderTopFirst ? limit - y.getValue() + client.textRenderer.fontHeight : y.getValue(),
Expand Down Expand Up @@ -407,7 +407,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {

if (focused && !isMinimalist()) {
drawOutline(
matrixStack,
context,
leftX,
getActualY(0) - scaledHeight - 1,
scaledWidth,
Expand All @@ -418,57 +418,56 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
String label = tab.getAbbreviation();
int labelWidth = StringUtils.getStringWidth(label) + 8;
drawRect(
matrixStack,
context,
leftX,
getActualY(newY),
labelWidth,
scaledBar,
tab.getMainColor().color());
drawOutline(
matrixStack,
context,
leftX,
getActualY(newY),
labelWidth,
scaledBar,
tab.getBorderColor().color());
DrawableHelper.drawCenteredTextWithShadow(
matrixStack,
context.drawCenteredTextWithShadow(
MinecraftClient.getInstance().textRenderer,
tab.getAbbreviation(),
leftX + (labelWidth) / 2,
getActualY(newY - 3),
Colors.getInstance().getColorOrWhite("white").color());
drawRect(
matrixStack,
context,
leftX + labelWidth,
getActualY(newY),
getScaledWidth() - labelWidth,
scaledBar,
selected ? tab.getMainColor().color() : tab.getInnerColor().color());
drawOutline(
matrixStack,
context,
leftX + labelWidth,
getActualY(newY),
getScaledWidth() - labelWidth,
scaledBar,
tab.getBorderColor().color());

drawOutline(
matrixStack,
context,
rightX - scaledBar,
getActualY(newY),
scaledBar,
scaledBar,
tab.getBorderColor().color());
drawOutline(
matrixStack,
context,
rightX - scaledBar * 2 + 1,
getActualY(newY),
scaledBar,
scaledBar,
tab.getBorderColor().color());
drawOutline(
matrixStack,
context,
rightX - scaledBar * 3 + 2,
getActualY(newY),
scaledBar,
Expand All @@ -478,8 +477,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
// Close
RenderUtils.color(1, 1, 1, 1);
RenderUtils.bindTexture(X_ICON);
DrawableHelper.drawTexture(
matrixStack,
context.drawTexture(
X_ICON,
rightX - scaledBar + 1,
getActualY(newY - 1),
scaledBar - 2,
Expand All @@ -494,8 +493,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
// Resize
RenderUtils.color(1, 1, 1, 1);
RenderUtils.bindTexture(RESIZE_ICON);
DrawableHelper.drawTexture(
matrixStack,
context.drawTexture(
RESIZE_ICON,
rightX - scaledBar * 2 + 2,
getActualY(newY - 1),
scaledBar - 2,
Expand All @@ -509,8 +508,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {

// Visibility
RenderUtils.bindTexture(visibility.getTexture());
DrawableHelper.drawTexture(
matrixStack,
context.drawTexture(
visibility.getTexture(),
rightX - scaledBar * 3 + 3,
getActualY(newY - 1),
scaledBar - 2,
Expand All @@ -525,8 +524,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
double mouseX = client.mouse.getX() / 2;
double mouseY = client.mouse.getY() / 2;
if (isMouseOverVisibility(mouseX, mouseY)) {
DrawableHelper.drawCenteredTextWithShadow(
matrixStack,
context.drawCenteredTextWithShadow(
client.textRenderer,
visibility.getDisplayName(),
(int) (mouseX / getScale() + 4),
Expand All @@ -539,7 +537,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
if (y.getValue() < getScaledHeight()) {
// Check to see if we've already gone above the boundaries
fill(
matrixStack,
context,
leftX,
getActualY(renderTopFirst ? limit - y.getValue() : y.getValue()),
rightX,
Expand All @@ -550,18 +548,18 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) {
float add = (float) (scrolledHeight) / (getTotalHeight());
int scrollHeight = (int) (add * (getScaledHeight() - 10));
drawRect(
matrixStack,
context,
getScaledWidth() + leftX - 1,
getActualY(scrollHeight + 10),
1,
10,
Colors.getInstance().getColorOrWhite("white").color());
}
matrixStack.pop();
context.getMatrices().pop();
}

private void drawLine(
MatrixStack matrixStack,
DrawContext context,
ChatMessage.AdvancedChatLine line,
int x,
int y,
Expand Down Expand Up @@ -656,9 +654,9 @@ private void drawLine(
backgroundY -= 1 + HudConfigStorage.General.TOP_PAD.config.getIntegerValue();
}
if (renderRight) {
drawRect(matrixStack, x + (scaledWidth - backgroundWidth), backgroundY, backgroundWidth, height, background.color());
drawRect(context, x + (scaledWidth - backgroundWidth), backgroundY, backgroundWidth, height, background.color());
} else {
drawRect(matrixStack, x, backgroundY, backgroundWidth, height, background.color());
drawRect(context, x, backgroundY, backgroundWidth, height, background.color());
}
if (lineIndex == line.getParent().getLineCount() - 1
&& line.getParent().getOwner() != null
Expand All @@ -675,15 +673,14 @@ private void drawLine(
headX = pLX - 10;
}
int headY = getActualY(y);
DrawableHelper.drawTexture(
matrixStack, headX, headY, 8, 8, 8, 8, 8, 8, 64, 64);
DrawableHelper.drawTexture(
matrixStack, headX, headY, 8, 8, 40, 8, 8, 8, 64, 64);
context.drawTexture(
line.getParent().getOwner().getTexture(), headX, headY, 8, 8, 8, 8, 8, 8, 64, 64);
context.drawTexture(
line.getParent().getOwner().getTexture(), headX, headY, 8, 8, 40, 8, 8, 8, 64, 64);
RenderSystem.setShaderColor(1, 1, 1, 1);
}

client.textRenderer.drawWithShadow(
matrixStack, render.asOrderedText(), renderRight ? pRX - lineWidth : pLX, getActualY(y) + 1, text.color());
context.drawTextWithShadow(
client.textRenderer, render.asOrderedText(), renderRight ? pRX - lineWidth : pLX, getActualY(y) + 1, text.color());
}

public Style getText(double mouseX, double mouseY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Style;
Expand Down Expand Up @@ -101,15 +102,15 @@ public void initGui() {
AbstractChatTab tab = chatWindow.getTab();
if (tab instanceof CustomChatTab custom) {
getScreen().getChatField().setText(custom.getStartingMessage());
getScreen().getChatField().setCursor(custom.getStartingMessage().length());
getScreen().getChatField().setCursor(custom.getStartingMessage().length(), false);
}
}
}

@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
if (menu != null) {
menu.render(mouseX, mouseY, true, matrixStack);
menu.render(mouseX, mouseY, true, context);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.github.darkkronicle.advancedchathud.config.HudConfigStorage;
import io.github.darkkronicle.advancedchathud.itf.IChatHud;
import io.github.darkkronicle.advancedchathud.tabs.AbstractChatTab;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
Expand All @@ -36,7 +37,7 @@ private TabButton(AbstractChatTab tab, int x, int y, int width, int height) {
}

@Override
public void render(int mouseX, int mouseY, boolean unused, MatrixStack matrixStack) {
public void render(int mouseX, int mouseY, boolean unused, DrawContext context) {
int relMX = mouseX - x;
int relMY = mouseY - y;
hovered = relMX >= 0 && relMX <= width && relMY >= 0 && relMY <= height;
Expand All @@ -61,15 +62,15 @@ public void render(int mouseX, int mouseY, boolean unused, MatrixStack matrixSta
RenderUtils.drawRect(x, y, width, height, color.color());

drawStringWithShadow(
x + PADDING, y + PADDING, selected ? WHITE : GRAY, displayString, matrixStack);
x + PADDING, y + PADDING, selected ? WHITE : GRAY, displayString, context);
if (tab.isShowUnread() && tab.getUnread() > 0) {
String unread = TextUtil.toSuperscript(Math.min(tab.getUnread(), 99));
drawCenteredString(
x + width - ((UNREAD_WIDTH + PADDING) / 2) - 1,
y + PADDING,
RED,
unread,
matrixStack);
context);
}
}

Expand Down
Loading