From 2a05ede2bf9331aafdf51a8eef67168908fe826d Mon Sep 17 00:00:00 2001 From: djlawler Date: Tue, 4 Jul 2023 10:26:57 -0400 Subject: [PATCH 1/4] create working 1.19.4 version (and branch) --- build.gradle | 2 +- .../client/gui/GuiItemDurability.java | 44 +++++++++---------- .../handler/MMConfigurationHandler.java | 2 +- .../mixin/PotionEffectsMixin.java | 10 ++--- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index a414906..82a8fff 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ sourceCompatibility = 17 targetCompatibility = 17 ext.Versions = new Properties() -Versions.load(file("Versionfiles/mcversion-1.20.properties").newReader()) +Versions.load(file("Versionfiles/mcversion-1.19.4.properties").newReader()) archivesBaseName = "durabilityviewer" ext.projectVersion = "1.10.4" diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java b/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java index 255c80c..2fdfa00 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java @@ -18,7 +18,7 @@ import java.util.Optional; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.util.Window; import net.minecraft.client.util.math.MatrixStack; @@ -141,7 +141,7 @@ private enum RenderPos { left, over, right; } - public void onRenderGameOverlayPost(DrawContext context, float partialTicks) { + public void onRenderGameOverlayPost(MatrixStack stack, float partialTicks) { PlayerEntity player = (PlayerEntity) minecraft.player; ItemStack needToWarn=null; @@ -206,7 +206,7 @@ public void onRenderGameOverlayPost(DrawContext context, float partialTicks) { long timeSinceLastWarning = System.currentTimeMillis() - lastWarningTime; if (timeSinceLastWarning < 1000 && (ConfigurationHandler.getWarnMode() & 2) == 2) { - renderItemBreakingOverlay(context, lastWarningItem, timeSinceLastWarning); + renderItemBreakingOverlay(stack, lastWarningItem, timeSinceLastWarning); } // Moved this check to down here, in order to play the @@ -228,10 +228,10 @@ public void onRenderGameOverlayPost(DrawContext context, float partialTicks) { if (ConfigurationHandler.getArmorAroundHotbar()) { armorSize = new RenderSize(0, 0); } else { - armorSize=this.renderItems(context, 0, 0, false, RenderPos.left, 0, boots, leggings, colytra, chestplate, helmet); + armorSize=this.renderItems(stack, 0, 0, false, RenderPos.left, 0, boots, leggings, colytra, chestplate, helmet); } - toolsSize=this.renderItems(context, 0, 0, false, RenderPos.right, 0, invSlots, mainHand, offHand, arrows); - trinketsSize = this.renderItems(context, 0, 0, false, RenderPos.left, 0, trinkets); + toolsSize=this.renderItems(stack, 0, 0, false, RenderPos.right, 0, invSlots, mainHand, offHand, arrows); + trinketsSize = this.renderItems(stack, 0, 0, false, RenderPos.left, 0, trinkets); int totalHeight=(toolsSize.height > armorSize.height ? toolsSize.height : armorSize.height); if (trinketsSize.height > totalHeight) { totalHeight = trinketsSize.height; } @@ -283,24 +283,24 @@ public void onRenderGameOverlayPost(DrawContext context, float partialTicks) { } int helmetTextWidth = fontRenderer.getWidth(helmet.getDisplayValue()); int chestTextWidth = fontRenderer.getWidth(chestplate.getDisplayValue()); - this.renderItems(context, mainWindow.getScaledWidth()/2+leftOffset - helmetTextWidth, mainWindow.getScaledHeight()-iconHeight*2-2, true, RenderPos.left, helmetTextWidth+iconWidth+spacing, helmet); - this.renderItems(context, mainWindow.getScaledWidth()/2+leftOffset - chestTextWidth, mainWindow.getScaledHeight()-iconHeight-2, true, RenderPos.left, chestTextWidth+iconWidth+spacing, chestplate); + this.renderItems(stack, mainWindow.getScaledWidth()/2+leftOffset - helmetTextWidth, mainWindow.getScaledHeight()-iconHeight*2-2, true, RenderPos.left, helmetTextWidth+iconWidth+spacing, helmet); + this.renderItems(stack, mainWindow.getScaledWidth()/2+leftOffset - chestTextWidth, mainWindow.getScaledHeight()-iconHeight-2, true, RenderPos.left, chestTextWidth+iconWidth+spacing, chestplate); if (colytra != null) { int colytraTextWidth = fontRenderer.getWidth(colytra.getDisplayValue()); - this.renderItems(context, mainWindow.getScaledWidth()/2+leftOffset - chestTextWidth - colytraTextWidth - iconWidth, mainWindow.getScaledHeight()-iconHeight-2, true, RenderPos.left, colytraTextWidth+iconWidth+spacing, colytra); + this.renderItems(stack, mainWindow.getScaledWidth()/2+leftOffset - chestTextWidth - colytraTextWidth - iconWidth, mainWindow.getScaledHeight()-iconHeight-2, true, RenderPos.left, colytraTextWidth+iconWidth+spacing, colytra); } - this.renderItems(context, mainWindow.getScaledWidth()/2+rightOffset, mainWindow.getScaledHeight()-iconHeight*2-2, true, RenderPos.right, armorSize.width, leggings); - this.renderItems(context, mainWindow.getScaledWidth()/2+rightOffset, mainWindow.getScaledHeight()-iconHeight-2, true, RenderPos.right, armorSize.width, boots); + this.renderItems(stack, mainWindow.getScaledWidth()/2+rightOffset, mainWindow.getScaledHeight()-iconHeight*2-2, true, RenderPos.right, armorSize.width, leggings); + this.renderItems(stack, mainWindow.getScaledWidth()/2+rightOffset, mainWindow.getScaledHeight()-iconHeight-2, true, RenderPos.right, armorSize.width, boots); if (ConfigurationHandler.getCorner().isRight()) { xposTools += armorSize.width; } else { xposTools -= armorSize.width; } } else { - this.renderItems(context, xposArmor, ypos, true, ConfigurationHandler.getCorner().isLeft() ? RenderPos.left : RenderPos.right, armorSize.width, helmet, chestplate, colytra, leggings, boots); + this.renderItems(stack, xposArmor, ypos, true, ConfigurationHandler.getCorner().isLeft() ? RenderPos.left : RenderPos.right, armorSize.width, helmet, chestplate, colytra, leggings, boots); } - this.renderItems(context, xposTools, ypos, true, ConfigurationHandler.getCorner().isRight() ? RenderPos.right : RenderPos.left, toolsSize.width, invSlots, mainHand, offHand, arrows); - this.renderItems(context, xposTrinkets, ypos, true, ConfigurationHandler.getCorner().isRight() ? RenderPos.right : RenderPos.left, trinketsSize.width, trinkets); + this.renderItems(stack, xposTools, ypos, true, ConfigurationHandler.getCorner().isRight() ? RenderPos.right : RenderPos.left, toolsSize.width, invSlots, mainHand, offHand, arrows); + this.renderItems(stack, xposTrinkets, ypos, true, ConfigurationHandler.getCorner().isRight() ? RenderPos.right : RenderPos.left, trinketsSize.width, trinkets); } private ItemIndicator damageOrEnergy(PlayerEntity player, EquipmentSlot slot) { @@ -315,14 +315,14 @@ private ItemIndicator damageOrEnergy(PlayerEntity player, EquipmentSlot slot) { return new ItemDamageIndicator(stack); } - private void renderItemBreakingOverlay(DrawContext context, ItemStack itemStack, long timeDelta) { + private void renderItemBreakingOverlay(MatrixStack matricies, ItemStack itemStack, long timeDelta) { Window mainWindow = MinecraftClient.getInstance().getWindow(); float alpha = 1.0f-((float)timeDelta/1000.0f); float xWarn = mainWindow.getScaledWidth()/2; float yWarn = mainWindow.getScaledHeight()/2; float scale = 5.0f; - context.fill(0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(), + DrawableHelper.fill(matricies, 0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(), 0xff0000+ ((int)(alpha*128)<<24)); MatrixStack stack = RenderSystem.getModelViewStack(); @@ -330,7 +330,7 @@ private void renderItemBreakingOverlay(DrawContext context, ItemStack itemStack, stack.scale(scale, scale, scale); RenderSystem.applyModelViewMatrix(); - context.drawItem(itemStack, (int)((xWarn)/scale-8), (int)((yWarn)/scale-8)); + itemRenderer.renderGuiItemIcon(stack, itemStack, (int)((xWarn)/scale-8), (int)((yWarn)/scale-8)); stack.pop(); RenderSystem.applyModelViewMatrix(); @@ -338,7 +338,7 @@ private void renderItemBreakingOverlay(DrawContext context, ItemStack itemStack, RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); } - public void afterRenderStatusEffects(DrawContext context, float partialTicks) { + public void afterRenderStatusEffects(MatrixStack stack, float partialTicks) { if (ConfigurationHandler.showEffectDuration()) { // a lot of this is copied from net/minecraft/client/gui/GuiIngame.java Window mainWindow = MinecraftClient.getInstance().getWindow(); @@ -360,13 +360,13 @@ public void afterRenderStatusEffects(DrawContext context, float partialTicks) { show=(duration/1200)+"m"; else show=(duration/20)+"s"; - context.drawTextWithShadow(fontRenderer, show, xpos+2, ypos, ItemIndicator.color_yellow); + fontRenderer.draw(stack, show, xpos+2, ypos, ItemIndicator.color_yellow); } } } } - private RenderSize renderItems(DrawContext context, int xpos, int ypos, boolean reallyDraw, RenderPos numberPos, int maxWidth, ItemIndicator... items) { + private RenderSize renderItems(MatrixStack stack, int xpos, int ypos, boolean reallyDraw, RenderPos numberPos, int maxWidth, ItemIndicator... items) { RenderSize result=new RenderSize(0, 0); for (ItemIndicator item: items) { @@ -377,8 +377,8 @@ private RenderSize renderItems(DrawContext context, int xpos, int ypos, boolean result.width=width; if (reallyDraw) { int color=item.getDisplayColor(); - context.drawItem(item.getItemStack(), numberPos == RenderPos.left ? xpos+maxWidth-iconWidth-spacing : xpos, ypos+result.height); - context.drawTextWithShadow(fontRenderer, displayString, numberPos != RenderPos.right ? xpos : xpos+iconWidth+spacing, ypos+result.height+fontRenderer.fontHeight/2 + (numberPos==RenderPos.over ? 10 : 0), color); + itemRenderer.renderGuiItemIcon(stack, item.getItemStack(), numberPos == RenderPos.left ? xpos+maxWidth-iconWidth-spacing : xpos, ypos+result.height); + fontRenderer.draw(stack, displayString, numberPos != RenderPos.right ? xpos : xpos+iconWidth+spacing, ypos+result.height+fontRenderer.fontHeight/2 + (numberPos==RenderPos.over ? 10 : 0), color); } result.height+=16; } diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java b/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java index 9748228..7b54fb2 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java @@ -10,6 +10,6 @@ public class MMConfigurationHandler implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { - return screen -> GuiModOptions.getGuiModOptions(screen, DurabilityViewer.MODNAME, ConfigurationProvider.getHandler(DurabilityViewer.MODNAME)); + return screen -> new GuiModOptions(screen, DurabilityViewer.MODNAME, ConfigurationProvider.getHandler(DurabilityViewer.MODNAME)); } } diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/mixin/PotionEffectsMixin.java b/src/main/java/de/guntram/mcmod/durabilityviewer/mixin/PotionEffectsMixin.java index 968579d..3d35bc0 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/mixin/PotionEffectsMixin.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/mixin/PotionEffectsMixin.java @@ -2,12 +2,12 @@ import de.guntram.mcmod.durabilityviewer.client.gui.GuiItemDurability; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.gui.DrawContext; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.client.util.math.MatrixStack; @Mixin(InGameHud.class) public abstract class PotionEffectsMixin { @@ -16,10 +16,10 @@ public abstract class PotionEffectsMixin { @Inject(method="renderStatusEffectOverlay", at=@At("RETURN")) - private void afterRenderStatusEffects(DrawContext context, CallbackInfo ci) { + private void afterRenderStatusEffects(MatrixStack stack, CallbackInfo ci) { if (gui==null) gui=new GuiItemDurability(); - gui.afterRenderStatusEffects(context, 0); + gui.afterRenderStatusEffects(stack, 0); } @Inject(method="render", at=@At( @@ -27,9 +27,9 @@ private void afterRenderStatusEffects(DrawContext context, CallbackInfo ci) { target="Lnet/minecraft/client/option/GameOptions;debugEnabled:Z", opcode = Opcodes.GETFIELD, args = {"log=false"})) - private void beforeRenderDebugScreen(DrawContext context, float f, CallbackInfo ci) { + private void beforeRenderDebugScreen(MatrixStack stack, float f, CallbackInfo ci) { if (gui==null) gui=new GuiItemDurability(); - gui.onRenderGameOverlayPost(context, 0); + gui.onRenderGameOverlayPost(stack, 0); } } From 02658ae6da175c7328b4d9a3f61e9e9a66b8825e Mon Sep 17 00:00:00 2001 From: djlawler Date: Tue, 4 Jul 2023 16:38:29 -0400 Subject: [PATCH 2/4] create working 1.19.4 version (and branch) - take two --- build.gradle | 5 +++-- .../durabilityviewer/handler/MMConfigurationHandler.java | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 82a8fff..98b7f6e 100644 --- a/build.gradle +++ b/build.gradle @@ -71,8 +71,9 @@ dependencies { modImplementation "com.terraformersmc:modmenu:${Versions['modmenu_version']}" modImplementation "de.guntram.mcmod:crowdin-translate:${Versions['crowdintranslate_version']}" include "de.guntram.mcmod:crowdin-translate:${Versions['crowdintranslate_version']}" - - modImplementation "de.guntram.mcmod:GBfabrictools:${Versions['gbfabrictools_version']}" + + compileOnly files('RoughlyEnoughItems-6.0.262-alpha-fabric.jar'); + modImplementation files('GBfabrictools-1.4+1.19.4.jar'); include "de.guntram.mcmod:GBfabrictools:${Versions['gbfabrictools_version']}" modImplementation "dev.emi:trinkets:3.0.0" diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java b/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java index 7b54fb2..67672e4 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/handler/MMConfigurationHandler.java @@ -6,10 +6,9 @@ import de.guntram.mcmod.fabrictools.ConfigurationProvider; import de.guntram.mcmod.fabrictools.GuiModOptions; -public class MMConfigurationHandler implements ModMenuApi -{ +public class MMConfigurationHandler implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { - return screen -> new GuiModOptions(screen, DurabilityViewer.MODNAME, ConfigurationProvider.getHandler(DurabilityViewer.MODNAME)); + return screen -> GuiModOptions.getGuiModOptions(screen, DurabilityViewer.MODNAME, ConfigurationProvider.getHandler(DurabilityViewer.MODNAME)); } -} +} \ No newline at end of file From ba4064dadaa2be262274499e9e026b28c88fbe7a Mon Sep 17 00:00:00 2001 From: djlawler Date: Tue, 4 Jul 2023 16:58:20 -0400 Subject: [PATCH 3/4] create working 1.19.4 version (and branch) - one last tweak --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 98b7f6e..9219f7b 100644 --- a/build.gradle +++ b/build.gradle @@ -73,7 +73,8 @@ dependencies { include "de.guntram.mcmod:crowdin-translate:${Versions['crowdintranslate_version']}" compileOnly files('RoughlyEnoughItems-6.0.262-alpha-fabric.jar'); - modImplementation files('GBfabrictools-1.4+1.19.4.jar'); + //modImplementation files('GBfabrictools-1.4+1.19.4.jar'); + modImplementation "de.guntram.mcmod:GBfabrictools:${Versions['gbfabrictools_version']}" include "de.guntram.mcmod:GBfabrictools:${Versions['gbfabrictools_version']}" modImplementation "dev.emi:trinkets:3.0.0" From 48b6da5d4b8d439011c2d496ea14e9641d73449f Mon Sep 17 00:00:00 2001 From: djlawler Date: Tue, 4 Jul 2023 17:05:48 -0400 Subject: [PATCH 4/4] create working 1.19.4 version (and branch) - spelling issue --- .../mcmod/durabilityviewer/client/gui/GuiItemDurability.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java b/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java index 2fdfa00..50e0417 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java @@ -315,14 +315,14 @@ private ItemIndicator damageOrEnergy(PlayerEntity player, EquipmentSlot slot) { return new ItemDamageIndicator(stack); } - private void renderItemBreakingOverlay(MatrixStack matricies, ItemStack itemStack, long timeDelta) { + private void renderItemBreakingOverlay(MatrixStack matrices, ItemStack itemStack, long timeDelta) { Window mainWindow = MinecraftClient.getInstance().getWindow(); float alpha = 1.0f-((float)timeDelta/1000.0f); float xWarn = mainWindow.getScaledWidth()/2; float yWarn = mainWindow.getScaledHeight()/2; float scale = 5.0f; - DrawableHelper.fill(matricies, 0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(), + DrawableHelper.fill(matrices, 0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(), 0xff0000+ ((int)(alpha*128)<<24)); MatrixStack stack = RenderSystem.getModelViewStack();