diff --git a/README.md b/README.md index 8633cc5..db95b99 100644 --- a/README.md +++ b/README.md @@ -16,21 +16,26 @@ PurpurClient is designed to work together with [Purpur](https://github.com/Purpu -### Current Features in 1.19: +### Current Features in 1.20.1: * Customizable mob passenger offsets * Adds bee counts inside beehives to debug screen¹ -* Prevent client from preemptively removing item entities from the world +* Fancy Purpur-themed Loading Screen (can be disabled in the config) +* Fancy Window Title that changes based on what kind of server you're in ([translations can be PR'd](./src/main/resources/assets/purpurclient/lang/)) +* Displays Custom Enchantments instead of stripping them from the client +* Removes the client-side limit of 255 levels ¹ only works when connected to [Purpur](https://github.com/PurpurMC/Purpur) servers ### Past Features (to get an idea of what this mod has done and will do in the future): -* Asynchronous chat processing (not updating this to 1.19 because Mojang's new chat system confuses me) +* Asynchronous chat processing (removed since Mojang's new chat system is confusing) * Fix rain particles appearing under water [MC-131770](https://bugs.mojang.com/browse/MC-131770) * Fix sky darkening when riding minecart not on tracks [MC-51150](https://bugs.mojang.com/browse/MC-51150) * Fix chat stutter [MC-218167](https://bugs.mojang.com/browse/MC-218167) * Fix warnings in logs about invalid flying attributes [Purpur-744](https://github.com/PurpurMC/Purpur/pull/744) +* Fix debug markers ignoring the blue and red values that are set [MC-234030](https://bugs.mojang.com/browse/MC-234030) (Shows as Unresolved even though it's been fixed) +* Fix client preemptively removing item entities from the world (MC-???) Note: PurpurClient adds a fancy animated splash screen on game startup alongside a better window title message. Both of these can be disabled in the config if preferred. diff --git a/build.gradle b/build.gradle index f3949bf..93b68ec 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'com.github.johnrengelman.shadow' version '7.1.2' - id 'fabric-loom' version '1.0-SNAPSHOT' + id 'fabric-loom' version '1.3-SNAPSHOT' id "com.modrinth.minotaur" version "2.+" } @@ -55,6 +55,7 @@ jar { loom { mixin.defaultRefmapName = "purpurclient.refmap.json" + accessWidenerPath = file("src/main/resources/purpurclient.accesswidener") } modrinth { diff --git a/gradle.properties b/gradle.properties index fae2164..c711a47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ org.gradle.jvmargs=-Xmx2G -minecraft_version=1.19.3 -yarn_mappings=1.19.3+build.1 -loader_version=0.14.11 -fabric_version=0.68.1+1.19.3 -modmenu_version=5.0.2 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.10 +loader_version=0.14.22 +fabric_version=0.88.1+1.20.1 +modmenu_version=7.2.2 configurate_version=4.1.2 maven_group=org.purpurmc.purpur.client diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/org/purpurmc/purpur/client/PurpurClient.java b/src/main/java/org/purpurmc/purpur/client/PurpurClient.java index e98f976..5073dfd 100644 --- a/src/main/java/org/purpurmc/purpur/client/PurpurClient.java +++ b/src/main/java/org/purpurmc/purpur/client/PurpurClient.java @@ -1,12 +1,18 @@ package org.purpurmc.purpur.client; import com.google.common.io.ByteArrayDataOutput; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.util.Icons; import net.minecraft.client.util.Window; import net.minecraft.resource.DefaultResourcePack; +import net.minecraft.resource.InputSupplier; import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; import org.purpurmc.purpur.client.config.Config; @@ -22,6 +28,8 @@ public static PurpurClient instance() { return instance; } + public static List> ICON_LIST = Arrays.asList(() -> PurpurClient.class.getResourceAsStream("/assets/icon16.png"), () -> PurpurClient.class.getResourceAsStream("/assets/icon32.png")); + private final ConfigManager configManager; public PurpurClient() { @@ -65,16 +73,11 @@ public void updateTitle() { MinecraftClient client = MinecraftClient.getInstance(); Window window = client.getWindow(); client.updateWindowTitle(); - if (getConfig().useWindowTitle) { - window.setIcon( - () -> PurpurClient.class.getResourceAsStream("/assets/icon16.png"), - () -> PurpurClient.class.getResourceAsStream("/assets/icon32.png")); - } else { - DefaultResourcePack pack = client.getDefaultResourcePack(); - window.setIcon( - pack.open(ResourceType.CLIENT_RESOURCES, new Identifier("icons/icon_16x16.png")), - pack.open(ResourceType.CLIENT_RESOURCES, new Identifier("icons/icon_32x32.png")) - ); - } + DefaultResourcePack pack = client.getDefaultResourcePack(); + try { + window.setIcon(pack, Icons.RELEASE); + } catch (IOException e) { + // ignore + }; } } diff --git a/src/main/java/org/purpurmc/purpur/client/gui/screen/AbstractScreen.java b/src/main/java/org/purpurmc/purpur/client/gui/screen/AbstractScreen.java index 36481f1..a4f777c 100644 --- a/src/main/java/org/purpurmc/purpur/client/gui/screen/AbstractScreen.java +++ b/src/main/java/org/purpurmc/purpur/client/gui/screen/AbstractScreen.java @@ -1,5 +1,6 @@ package org.purpurmc.purpur.client.gui.screen; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.Drawable; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ClickableWidget; @@ -30,18 +31,18 @@ public void init() { } @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) { - renderBackground(matrixStack); - drawCenteredText(matrixStack, this.textRenderer, this.title, this.centerX, 15, 0xFFFFFFFF); - super.render(matrixStack, mouseX, mouseY, delta); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + renderBackground(context); + context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.centerX, 15, 0xFFFFFFFF); + super.render(context, mouseX, mouseY, delta); } @Override - public void renderBackground(MatrixStack matrixStack, int vOffset) { + public void renderBackground(DrawContext context) { if (this.client != null && this.client.world != null) { - this.fillGradient(matrixStack, 0, 0, this.width, this.height, 0xF00F4863, 0xF0370038); + context.fillGradient(0, 0, this.width, this.height, 0xF00F4863, 0xF0370038); } else { - this.renderBackgroundTexture(vOffset); + this.renderBackgroundTexture(context); } } @@ -53,19 +54,21 @@ public void close() { PurpurClient.instance().getConfigManager().save(); } - @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode == GLFW.GLFW_KEY_TAB) { - for (Drawable drawable : this.options) { - if (drawable instanceof DoubleButton option) { - if (option.tab()) { - return false; - } - } - } - } - return super.keyPressed(keyCode, scanCode, modifiers); - } +// TODO: fix keyboard accessibility in mob settings +// +// @Override +// public boolean keyPressed(int keyCode, int scanCode, int modifiers) { +// if (keyCode == GLFW.GLFW_KEY_TAB) { +// for (Drawable drawable : this.options) { +// if (drawable instanceof DoubleButton option) { +// if (option.tab()) { +// return false; +// } +// } +// } +// } +// return super.keyPressed(keyCode, scanCode, modifiers); +// } @Override public void tick() { diff --git a/src/main/java/org/purpurmc/purpur/client/gui/screen/MobScreen.java b/src/main/java/org/purpurmc/purpur/client/gui/screen/MobScreen.java index 19d42f2..9f789a0 100644 --- a/src/main/java/org/purpurmc/purpur/client/gui/screen/MobScreen.java +++ b/src/main/java/org/purpurmc/purpur/client/gui/screen/MobScreen.java @@ -2,6 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.Drawable; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.HandledScreen; @@ -139,8 +140,8 @@ public void init() { } @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) { - renderBackground(matrixStack); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + renderBackground(context); RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); @@ -149,21 +150,22 @@ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) if (this.fakePlayer != null && this.fakeEntity != null) { drawPreviewModel(this.fakePlayer, this.fakeEntity); } else { - drawCenteredText(matrixStack, this.textRenderer, this.noPreview, this.centerX - 80, 125, 0xFFFFFFFF); + context.drawCenteredTextWithShadow(this.textRenderer, this.noPreview, this.centerX - 80, 125, 0xFFFFFFFF); } - matrixStack.push(); - matrixStack.translate(0, 0, 900); - drawCenteredText(matrixStack, this.textRenderer, this.title, this.centerX, 15, 0xFFFFFFFF); - drawCenteredText(matrixStack, this.textRenderer, this.subtitle, this.centerX, 30, 0xFFFFFFFF); + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.translate(0, 0, 900); + context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.centerX, 15, 0xFFFFFFFF); + context.drawCenteredTextWithShadow(this.textRenderer, this.subtitle, this.centerX, 30, 0xFFFFFFFF); if (this.options == null || this.options.isEmpty()) { - drawCenteredText(matrixStack, this.textRenderer, this.notImplemented, this.centerX + 120, 125, 0xFFFFFFFF); + context.drawCenteredTextWithShadow(this.textRenderer, this.notImplemented, this.centerX + 120, 125, 0xFFFFFFFF); } else { for (Drawable drawable : this.options) { - drawable.render(matrixStack, mouseX, mouseY, delta); + drawable.render(context, mouseX, mouseY, delta); } } - matrixStack.pop(); + matrices.pop(); } public void drawPreviewModel(FakePlayer player, Entity vehicle) { @@ -246,8 +248,8 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del return false; } if (button == 0) { - this.previewYaw -= (mouseX - this.mouseDownX); - this.previewPitch -= (mouseY - this.mouseDownY); + this.previewYaw -= (float) (mouseX - this.mouseDownX); + this.previewPitch -= (float) (mouseY - this.mouseDownY); clampYawPitch(); } else if (button == 1) { this.previewX += (mouseX - this.mouseDownX); @@ -260,7 +262,7 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del @Override public boolean mouseScrolled(double mouseX, double mouseY, double amount) { - this.previewZoom += amount; + this.previewZoom += (float) amount; clampZoom(); return true; } diff --git a/src/main/java/org/purpurmc/purpur/client/gui/screen/MobsScreen.java b/src/main/java/org/purpurmc/purpur/client/gui/screen/MobsScreen.java index d4802d3..b442b4c 100644 --- a/src/main/java/org/purpurmc/purpur/client/gui/screen/MobsScreen.java +++ b/src/main/java/org/purpurmc/purpur/client/gui/screen/MobsScreen.java @@ -1,5 +1,6 @@ package org.purpurmc.purpur.client.gui.screen; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.recipebook.SmokerRecipeBookScreen; import net.minecraft.client.util.math.MatrixStack; @@ -33,8 +34,8 @@ public void init() { } @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) { - super.render(matrixStack, mouseX, mouseY, delta); - drawCenteredText(matrixStack, this.textRenderer, OptionsScreen.MOBS_BTN, this.centerX, 30, 0xFFFFFFFF); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + super.render(context, mouseX, mouseY, delta); + context.drawCenteredTextWithShadow(this.textRenderer, OptionsScreen.MOBS_BTN, this.centerX, 30, 0xFFFFFFFF); } } diff --git a/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/BooleanButton.java b/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/BooleanButton.java index e070f3a..a8ac774 100644 --- a/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/BooleanButton.java +++ b/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/BooleanButton.java @@ -1,6 +1,7 @@ package org.purpurmc.purpur.client.gui.screen.widget; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.screen.narration.NarrationPart; import net.minecraft.client.gui.widget.ButtonWidget; @@ -17,17 +18,12 @@ public BooleanButton(int x, int y, int width, int height, BooleanOption option) this.option = option; } - public void renderTooltip(MatrixStack matrixStack, int mouseX, int mouseY) { + public void renderTooltip(DrawContext context, int mouseX, int mouseY) { if (this.hovered && this.tooltipDelay > 15 && MinecraftClient.getInstance().currentScreen != null) { - MinecraftClient.getInstance().currentScreen.renderOrderedTooltip(matrixStack, this.option.tooltip(), mouseX, mouseY); + context.drawOrderedTooltip(MinecraftClient.getInstance().textRenderer, this.option.tooltip(), mouseX, mouseY); } } - @Override - public void appendClickableNarrations(NarrationMessageBuilder builder) { - this.appendDefaultNarrations(builder); - } - @Override public Text getMessage() { return this.option.text(); @@ -35,7 +31,7 @@ public Text getMessage() { @Override public void tick() { - if (this.isHovered() && this.active) { + if (this.isSelected() && this.active) { this.tooltipDelay++; } else if (this.tooltipDelay > 0) { this.tooltipDelay = 0; diff --git a/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/DoubleButton.java b/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/DoubleButton.java index 767d04e..b7dd97f 100644 --- a/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/DoubleButton.java +++ b/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/DoubleButton.java @@ -2,6 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.widget.ClickableWidget; @@ -31,8 +32,8 @@ public DoubleButton(int x, int y, int width, int height, DoubleOption option) { } @Override - public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float delta) { - if (this.isHovered()) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) { + if (this.hovered) { if (mouseX >= this.getX() && mouseX < this.getX() + this.height) { this.btn = Btn.MINUS; } else if (mouseX >= this.getX() + this.width - this.height && mouseX < this.getX() + this.width) { @@ -44,26 +45,23 @@ public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float onRelease(0, 0); } - drawButton(matrixStack, MINUS, this.getX(), this.getYImage(this.btn == Btn.MINUS || this.selected == Btn.MINUS)); - drawButton(matrixStack, PLUS, this.getX() + this.width - this.height, this.getYImage(this.btn == Btn.PLUS || this.selected == Btn.PLUS)); + drawButton(context, MINUS, this.getX(), this.getYImage(this.btn == Btn.MINUS || this.selected == Btn.MINUS)); + drawButton(context, PLUS, this.getX() + this.width - this.height, this.getYImage(this.btn == Btn.PLUS || this.selected == Btn.PLUS)); - ClickableWidget.drawCenteredText(matrixStack, MinecraftClient.getInstance().textRenderer, this.getMessage(), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, (this.active ? 0xFFFFFF : 0xA0A0A0) | MathHelper.ceil(this.alpha * 255.0f) << 24); + context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, this.getMessage(), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, (this.active ? 0xFFFFFF : 0xA0A0A0) | MathHelper.ceil(this.alpha * 255.0f) << 24); if (this.hovered) { - this.renderTooltip(matrixStack, mouseX, mouseY); + this.renderTooltip(context, mouseX, mouseY); } } - private void drawButton(MatrixStack matrixStack, Text text, int x, int i) { - RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); + private void drawButton(DrawContext context, Text text, int x, int i) { RenderSystem.enableDepthTest(); - this.drawTexture(matrixStack, x, this.getY(), 0, 46 + i * 20, this.height / 2, this.height); - this.drawTexture(matrixStack, x + this.height / 2, this.getY(), 200 - this.height / 2, 46 + i * 20, this.height / 2, this.height); - ClickableWidget.drawCenteredText(matrixStack, MinecraftClient.getInstance().textRenderer, text, x + this.height / 2, this.getY() + (this.height - 8) / 2, (this.active ? 0xFFFFFF : 0xA0A0A0) | MathHelper.ceil(this.alpha * 255.0f) << 24); + context.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha); + RenderSystem.enableBlend(); + this.drawTexture(context, WIDGETS_TEXTURE, x, this.getY(), 0, 46 + i * 20, 0, this.height / 2, this.height, 256, 256); + this.drawTexture(context, WIDGETS_TEXTURE, x + this.height / 2, this.getY(), 200 - this.height / 2, 46 + i * 20, 0, this.height / 2, this.height, 256, 256); + context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, text, x + this.height / 2, this.getY() + (this.height - 8) / 2, (this.active ? 0xFFFFFF : 0xA0A0A0) | MathHelper.ceil(this.alpha * 255.0f) << 24); } @Override @@ -76,7 +74,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { this.onClick(mouseX, mouseY); return true; } - return isHovered(); + return isSelected(); } @Override @@ -94,29 +92,33 @@ public void onClick(double mouseX, double mouseY) { public void onRelease(double mouseX, double mouseY) { this.btn = null; this.mouseDownTicks = 0; + this.setFocused(false); } - public void renderTooltip(MatrixStack matrixStack, int mouseX, int mouseY) { + public void renderTooltip(DrawContext context, int mouseX, int mouseY) { if (this.tooltipDelay > 15 && MinecraftClient.getInstance().currentScreen != null) { - matrixStack.push(); - matrixStack.translate(0, 0, -399); - MinecraftClient.getInstance().currentScreen.renderOrderedTooltip(matrixStack, this.option.tooltip(), mouseX, mouseY); - matrixStack.pop(); + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.translate(0, 0, -399); + context.drawOrderedTooltip(MinecraftClient.getInstance().textRenderer, this.option.tooltip(), mouseX, mouseY); + matrices.pop(); } } - public boolean tab() { - if (isFocused()) { - if (this.btn == Btn.MINUS) { - this.selected = Btn.PLUS; - return true; - } else if (Screen.hasShiftDown() && this.btn == Btn.PLUS) { - this.selected = Btn.MINUS; - return true; - } - } - return false; - } +// TODO: fix keyboard accessibility in mob settings +// +// public boolean tab() { +// if (isFocused()) { +// if (this.btn == Btn.MINUS) { +// this.selected = Btn.PLUS; +// return true; +// } else if (Screen.hasShiftDown() && this.btn == Btn.PLUS) { +// this.selected = Btn.MINUS; +// return true; +// } +// } +// return false; +// } @Override public void appendClickableNarrations(NarrationMessageBuilder builder) { @@ -130,7 +132,7 @@ public Text getMessage() { @Override public void tick() { - if (this.isHovered() && this.active) { + if (this.isSelected() && this.active) { this.tooltipDelay++; } else if (this.tooltipDelay > 0) { this.tooltipDelay = 0; @@ -148,4 +150,15 @@ private void addValue(double value) { this.playDownSound(MinecraftClient.getInstance().getSoundManager()); this.option.set(this.option.get() + value); } + + private int getYImage(boolean hovered) { + int i = 1; + if (!this.active) { + i = 0; + } else if (hovered) { + i = 2; + } + + return i; + } } diff --git a/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/MobButton.java b/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/MobButton.java index 698852c..79c693c 100644 --- a/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/MobButton.java +++ b/src/main/java/org/purpurmc/purpur/client/gui/screen/widget/MobButton.java @@ -1,6 +1,8 @@ package org.purpurmc.purpur.client.gui.screen.widget; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.screen.narration.NarrationPart; import net.minecraft.client.gui.widget.ButtonWidget; @@ -23,43 +25,42 @@ public MobButton(AbstractScreen screen, Mob mob, int x, int y) { this.mob = mob; } - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) { RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderTexture(0, MOBS_TEXTURE); RenderSystem.enableDepthTest(); drawTexture( - matrices, + context, + MOBS_TEXTURE, this.getX(), this.getY(), this.width * 15, - this.height * 14 + (this.isHovered() ? this.height : 0), + this.height * 14 + (this.isSelected() ? this.height : 0), + 0, this.width, this.height, this.width * 16, this.height * 16 ); drawTexture( - matrices, + context, + MOBS_TEXTURE, this.getX(), this.getY(), this.mob.getU() * this.width, this.mob.getV() * this.height, + 0, this.width, this.height, this.width * 16, this.height * 16 ); if (this.hovered) { - this.renderTooltip(matrices, mouseX, mouseY); + this.renderTooltip(context, mouseX, mouseY); } } - public void renderTooltip(MatrixStack matrixStack, int mouseX, int mouseY) { - this.screen.renderTooltip(matrixStack, this.getMessage(), mouseX, mouseY); - } - - @Override - public void appendClickableNarrations(NarrationMessageBuilder builder) { - this.appendDefaultNarrations(builder); + public void renderTooltip(DrawContext context, int mouseX, int mouseY) { + context.drawTooltip(MinecraftClient.getInstance().textRenderer, this.getMessage(), mouseX, mouseY); } } diff --git a/src/main/java/org/purpurmc/purpur/client/mixin/GameTestDebugRendererMixin.java b/src/main/java/org/purpurmc/purpur/client/mixin/GameTestDebugRendererMixin.java deleted file mode 100644 index 0874250..0000000 --- a/src/main/java/org/purpurmc/purpur/client/mixin/GameTestDebugRendererMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.purpurmc.purpur.client.mixin; - -import net.minecraft.client.render.debug.GameTestDebugRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -@Mixin(GameTestDebugRenderer.class) -public class GameTestDebugRendererMixin { - @ModifyArgs(method = "renderMarker", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderColor(FFFF)V")) - private void injected(Args args) { - // show full colors, not just green - args.set(0, 1.0F); // red - args.set(1, 1.0F); // green - args.set(2, 1.0F); // blue - args.set(3, 0.75F); // alpha - } -} diff --git a/src/main/java/org/purpurmc/purpur/client/mixin/MixinDebugHud.java b/src/main/java/org/purpurmc/purpur/client/mixin/MixinDebugHud.java index b056361..2e3aaea 100644 --- a/src/main/java/org/purpurmc/purpur/client/mixin/MixinDebugHud.java +++ b/src/main/java/org/purpurmc/purpur/client/mixin/MixinDebugHud.java @@ -1,9 +1,20 @@ package org.purpurmc.purpur.client.mixin; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.platform.GlDebugInfo; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Map; import net.minecraft.block.BeehiveBlock; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.DebugHud; +import net.minecraft.entity.Entity; +import net.minecraft.fluid.FluidState; +import net.minecraft.registry.Registries; +import net.minecraft.state.property.Property; +import net.minecraft.util.Formatting; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; @@ -12,6 +23,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -25,11 +37,13 @@ public class MixinDebugHud { @Shadow private HitResult blockHit; + @Unique private long lastTime = 0; + @Unique private BlockPos lastPos = null; - @Redirect(method = "renderRightText", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;getRightText()Ljava/util/List;")) - protected List renderRightText(DebugHud instance) { + @Redirect(method = "drawRightText", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;getRightText()Ljava/util/List;")) + protected List drawRightText(DebugHud instance) { List list = this.getRightText(); if (this.client.hasReducedDebugInfo() || this.client.world == null || !PurpurClient.instance().getConfig().beeCountInDebug) { diff --git a/src/main/java/org/purpurmc/purpur/client/mixin/MixinItemEntity.java b/src/main/java/org/purpurmc/purpur/client/mixin/MixinItemEntity.java deleted file mode 100644 index c70a49b..0000000 --- a/src/main/java/org/purpurmc/purpur/client/mixin/MixinItemEntity.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.purpurmc.purpur.client.mixin; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.registry.tag.BlockTags; -import net.minecraft.registry.tag.FluidTags; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(ItemEntity.class) -public abstract class MixinItemEntity extends Entity { - public MixinItemEntity(EntityType entityType, World world) { - super(entityType, world); - } - - @Override - public boolean isInvulnerableTo(DamageSource damageSource) { - if (this.world.isClient) { - if (damageSource == DamageSource.CACTUS) return true; - if (damageSource.isFire() || damageSource == DamageSource.IN_FIRE) return true; - if (damageSource == DamageSource.LIGHTNING_BOLT) return true; - if (damageSource.isExplosive()) return true; - } - return super.isInvulnerableTo(damageSource); - } - - @Override - public boolean isInLava() { - return !this.firstUpdate && (this.fluidHeight.getDouble(FluidTags.LAVA) > 0.0D || this.world.getStatesInBoxIfLoaded(this.getBoundingBox().contract(1.0E-6D)).anyMatch((state) -> state.isIn(BlockTags.FIRE))); - } -} diff --git a/src/main/java/org/purpurmc/purpur/client/mixin/MixinSplashOverlay.java b/src/main/java/org/purpurmc/purpur/client/mixin/MixinSplashOverlay.java index d7e1685..4333d67 100644 --- a/src/main/java/org/purpurmc/purpur/client/mixin/MixinSplashOverlay.java +++ b/src/main/java/org/purpurmc/purpur/client/mixin/MixinSplashOverlay.java @@ -2,6 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.SplashOverlay; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -14,6 +15,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -42,6 +44,7 @@ public class MixinSplashOverlay { @Final private Consumer> exceptionHandler; + @Unique private float delta; @Inject(method = "init", at = @At("HEAD")) @@ -50,7 +53,7 @@ private static void init(MinecraftClient client, CallbackInfo ci) { } @Inject(method = "render", at = @At("HEAD"), cancellable = true) - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta, CallbackInfo ci) { + public void render(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { if (!PurpurClient.instance().getConfig().useSplashScreen) { return; } @@ -70,13 +73,13 @@ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta, if (f >= 1.0f) { if (this.client.currentScreen != null) { - this.client.currentScreen.render(matrixStack, 0, 0, delta); + this.client.currentScreen.render(context, 0, 0, delta); } this.delta = 0; opacity = 1.0f - MathHelper.clamp(f - 1.0f, 0.0f, 1.0f); } else if (this.reloading) { if (this.client.currentScreen != null && g < 1.0f) { - this.client.currentScreen.render(matrixStack, mouseX, mouseY, delta); + this.client.currentScreen.render(context, mouseX, mouseY, delta); } this.delta = 0; opacity = MathHelper.clamp(g, 0.0f, 1.0f); @@ -89,18 +92,18 @@ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta, RenderSystem.enableBlend(); RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, opacity); - SplashOverlay.drawTexture(matrixStack, 0, 0, width, height, 0, 0, 1024, 544, 1024, 1024); // background - SplashOverlay.drawTexture(matrixStack, (int) ((width - 112) * MathHelper.lerp(easeOut(opacity), 0.8D, 1.0D)), 10, 112, 112, 0, 546, 256, 256, 1024, 1024); // logo - SplashOverlay.drawTexture(matrixStack, 40 + (int) ((20) * -MathHelper.lerp(easeOut(opacity), 0.0D, 1.0D)), height - 70, 180, 17, 256, 548, 367, 33, 1024, 1024); // slogan - SplashOverlay.drawTexture(matrixStack, (int) ((20) * MathHelper.lerp(easeOut(opacity), -1.0D, 1.0D)), height - 50, 100, 30, 256, 587, 210, 61, 1024, 1024); // Purpur - SplashOverlay.drawTexture(matrixStack, width - 105, (int) ((height - 15) * MathHelper.lerp(easeOut(opacity), 0.75D, 1.0D)), 100, 12, 256, 658, 200, 23, 1024, 1024); // url + context.drawTexture(SplashTexture.SPLASH, 0, 0, width, height, 0, 0, 1024, 544, 1024, 1024); // background + context.drawTexture(SplashTexture.SPLASH, (int) ((width - 112) * MathHelper.lerp(easeOut(opacity), 0.8D, 1.0D)), 10, 112, 112, 0, 546, 256, 256, 1024, 1024); // logo + context.drawTexture(SplashTexture.SPLASH, 40 + (int) ((20) * -MathHelper.lerp(easeOut(opacity), 0.0D, 1.0D)), height - 70, 180, 17, 256, 548, 367, 33, 1024, 1024); // slogan + context.drawTexture(SplashTexture.SPLASH, (int) ((20) * MathHelper.lerp(easeOut(opacity), -1.0D, 1.0D)), height - 50, 100, 30, 256, 587, 210, 61, 1024, 1024); // Purpur + context.drawTexture(SplashTexture.SPLASH, width - 105, (int) ((height - 15) * MathHelper.lerp(easeOut(opacity), 0.75D, 1.0D)), 100, 12, 256, 658, 200, 23, 1024, 1024); // url RenderSystem.disableBlend(); int scale = (int) ((double) this.client.getWindow().getScaledHeight() * 0.625D); float reloadProgress = this.reload.getProgress(); this.progress = MathHelper.clamp(this.progress * 0.95f + reloadProgress * 0.050000012f, 0.0f, 1.0f); if (f < 1.0f) { - this.renderProgressBar(matrixStack, width / 2 - 100, scale - 5, width / 2 + 100, scale + 5, 1.0f - MathHelper.clamp(f, 0.0f, 1.0f)); + this.renderProgressBar(context, width / 2 - 100, scale - 5, width / 2 + 100, scale + 5, 1.0f - MathHelper.clamp(f, 0.0f, 1.0f)); } if (f >= 2.0f) { this.client.setOverlay(null); @@ -119,25 +122,29 @@ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta, } } - private void renderProgressBar(MatrixStack matrices, int minX, int minY, int maxX, int maxY, float opacity) { + @Unique + private void renderProgressBar(DrawContext context, int minX, int minY, int maxX, int maxY, float opacity) { int i = MathHelper.ceil((float) (maxX - minX - 2) * this.progress); int j = Math.round(opacity * 255.0f); int k = ColorHelper.Argb.getArgb(j, 255, 255, 255); - SplashOverlay.fill(matrices, minX + 2, minY + 2, minX + i, maxY - 2, k); - SplashOverlay.fill(matrices, minX + 1, minY, maxX - 1, minY + 1, k); - SplashOverlay.fill(matrices, minX + 1, maxY, maxX - 1, maxY - 1, k); - SplashOverlay.fill(matrices, minX, minY, minX + 1, maxY, k); - SplashOverlay.fill(matrices, maxX, minY, maxX - 1, maxY, k); + context.fill(minX + 2, minY + 2, minX + i, maxY - 2, k); + context.fill(minX + 1, minY, maxX - 1, minY + 1, k); + context.fill(minX + 1, maxY, maxX - 1, maxY - 1, k); + context.fill(minX, minY, minX + 1, maxY, k); + context.fill(maxX, minY, maxX - 1, maxY, k); } + @Unique private float easeIn(float t) { return t * t; } + @Unique private float easeOut(float t) { return flip(easeIn(flip(t))); } + @Unique private float flip(float x) { return 1 - x; } diff --git a/src/main/java/org/purpurmc/purpur/client/mixin/MixinWindow.java b/src/main/java/org/purpurmc/purpur/client/mixin/MixinWindow.java new file mode 100644 index 0000000..0370a3d --- /dev/null +++ b/src/main/java/org/purpurmc/purpur/client/mixin/MixinWindow.java @@ -0,0 +1,24 @@ +package org.purpurmc.purpur.client.mixin; + + +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; +import net.minecraft.client.util.Window; +import net.minecraft.resource.InputSupplier; +import org.purpurmc.purpur.client.PurpurClient; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(Window.class) +public class MixinWindow { + @ModifyVariable(method = "Lnet/minecraft/client/util/Window;setIcon(Lnet/minecraft/resource/ResourcePack;Lnet/minecraft/client/util/Icons;)V", at = @At("STORE"), ordinal = 0) + private List> modifyIconList(List> list) { + if (PurpurClient.instance().getConfig().useWindowTitle) { + return PurpurClient.ICON_LIST; + } else { + return list; + } + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fabf3bd..1a27df3 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,13 +23,14 @@ "org.purpurmc.purpur.client.gui.ModMenu" ] }, + "accessWidener": "purpurclient.accesswidener", "mixins": [ "purpurclient.mixins.json" ], "depends": { "fabricloader": ">=0.14.11", "fabric": "*", - "minecraft": "1.19.3" + "minecraft": "1.20.1" }, "custom": { "modmenu": { diff --git a/src/main/resources/purpurclient.accesswidener b/src/main/resources/purpurclient.accesswidener new file mode 100644 index 0000000..cd58ebc --- /dev/null +++ b/src/main/resources/purpurclient.accesswidener @@ -0,0 +1,4 @@ +accessWidener v2 named + +extendable method net/minecraft/entity/Entity updatePassengerPosition (Lnet/minecraft/entity/Entity;)V +extendable class net/minecraft/client/util/Window diff --git a/src/main/resources/purpurclient.mixins.json b/src/main/resources/purpurclient.mixins.json index 8fc1c0b..ff3ebc8 100644 --- a/src/main/resources/purpurclient.mixins.json +++ b/src/main/resources/purpurclient.mixins.json @@ -5,13 +5,12 @@ "compatibilityLevel": "JAVA_17", "refmap": "purpurclient.refmap.json", "mixins": [ - "GameTestDebugRendererMixin", "MixinDebugHud", "MixinEnchantmentHelper", - "MixinItemEntity", "MixinItemStack", "MixinMinecraftClient", "MixinSplashOverlay", + "MixinWindow", "accessor.AccessAbstractPiglin", "accessor.AccessEntity", "accessor.AccessHoglin",