Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Fabric 1 19 4 #92

Open
wants to merge 4 commits into
base: fabric_1_20
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
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -71,7 +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']}"


compileOnly files('RoughlyEnoughItems-6.0.262-alpha-fabric.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']}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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; }
Expand Down Expand Up @@ -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) {
Expand All @@ -315,30 +315,30 @@ private ItemIndicator damageOrEnergy(PlayerEntity player, EquipmentSlot slot) {
return new ItemDamageIndicator(stack);
}

private void renderItemBreakingOverlay(DrawContext context, 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;

context.fill(0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(),
DrawableHelper.fill(matrices, 0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(),
0xff0000+ ((int)(alpha*128)<<24));

MatrixStack stack = RenderSystem.getModelViewStack();
stack.push();
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();

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();
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> GuiModOptions.getGuiModOptions(screen, DurabilityViewer.MODNAME, ConfigurationProvider.getHandler(DurabilityViewer.MODNAME));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -16,20 +16,20 @@ 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(
value="FIELD",
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);
}
}