Skip to content

Commit

Permalink
Initial 1.19.4 support
Browse files Browse the repository at this point in the history
No ModMenu or TechReborn support
  • Loading branch information
TheMrEngMan committed Apr 30, 2023
1 parent 7ab14d3 commit 17c9298
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 78 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sourceCompatibility = 17
targetCompatibility = 17

ext.Versions = new Properties()
Versions.load(file("Versionfiles/mcversion-1.19.3.properties").newReader())
Versions.load(file("Versionfiles/mcversion-1.19.4.properties").newReader())

archivesBaseName = "durabilityviewer"
ext.projectVersion = "1.10.3"
Expand All @@ -66,15 +66,15 @@ dependencies {
mappings "net.fabricmc:yarn:${Versions['yarn_mappings']}:v2"
modImplementation "net.fabricmc:fabric-loader:${Versions['loader_version']}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${Versions['fabric_version']}"
modImplementation "TechReborn:TechReborn-1.16:3.4.5+build.95"
modImplementation "com.terraformersmc:modmenu:${Versions['modmenu_version']}"
// modImplementation "TechReborn:TechReborn-1.16:3.4.5+build.95"
modImplementation "com.terraformersmc:modmenu:6.2.2"
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']}"
include "de.guntram.mcmod:GBfabrictools:${Versions['gbfabrictools_version']}"

modImplementation "dev.emi:trinkets:3.0.0"
modImplementation "dev.emi:trinkets:3.6.0"
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import net.minecraft.util.Arm;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import team.reborn.energy.EnergyHolder;
//import team.reborn.energy.EnergyHolder;


public class GuiItemDurability
Expand Down Expand Up @@ -307,11 +307,12 @@ private ItemIndicator damageOrEnergy(PlayerEntity player, EquipmentSlot slot) {
ItemStack stack = player.getEquippedStack(slot);
if (stack.isDamageable()) {
return new ItemDamageIndicator(stack);
} else if (haveTRCore) {
if (stack.getItem() instanceof EnergyHolder && stack.getNbt()!=null && stack.getNbt().contains("energy", 6)) {
return new TREnergyIndicator(stack);
}
}
// else if (haveTRCore) {
// if (stack.getItem() instanceof EnergyHolder && stack.getNbt()!=null && stack.getNbt().contains("energy", 6)) {
// return new TREnergyIndicator(stack);
// }
// }
return new ItemDamageIndicator(stack);
}

Expand All @@ -324,16 +325,13 @@ private void renderItemBreakingOverlay(MatrixStack matrices, ItemStack itemStack

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

matrices.push();
matrices.scale(scale, scale, scale);

MatrixStack stack = RenderSystem.getModelViewStack();
stack.push();
stack.scale(scale, scale, scale);
RenderSystem.applyModelViewMatrix();

itemRenderer.renderGuiItemIcon(itemStack, (int)((xWarn)/scale-8), (int)((yWarn)/scale-8));

stack.pop();
RenderSystem.applyModelViewMatrix();
itemRenderer.renderGuiItemIcon(matrices, itemStack, (int)((xWarn)/scale-8), (int)((yWarn)/scale-8));

matrices.pop();

RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
}
Expand Down Expand Up @@ -377,7 +375,7 @@ private RenderSize renderItems(MatrixStack stack, int xpos, int ypos, boolean re
result.width=width;
if (reallyDraw) {
int color=item.getDisplayColor();
itemRenderer.renderGuiItemIcon(item.getItemStack(), numberPos == RenderPos.left ? xpos+maxWidth-iconWidth-spacing : xpos, ypos+result.height);
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 @@ -10,6 +10,8 @@ public class MMConfigurationHandler implements ModMenuApi
{
@Override
public ConfigScreenFactory getModConfigScreenFactory() {
return screen -> new GuiModOptions(screen, DurabilityViewer.MODNAME, ConfigurationProvider.getHandler(DurabilityViewer.MODNAME));
// TODO: re-enable this once GBfabrictools is updated to 1.19.4
// return screen -> new GuiModOptions(screen, DurabilityViewer.MODNAME, ConfigurationProvider.getHandler(DurabilityViewer.MODNAME));
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,69 @@

import de.guntram.mcmod.durabilityviewer.handler.ConfigurationHandler;
import net.minecraft.item.ItemStack;
import team.reborn.energy.EnergyHolder;
//import team.reborn.energy.EnergyHolder;

/**
*
* @author gbl
*/
public class TREnergyIndicator implements ItemIndicator {
//public class TREnergyIndicator implements ItemIndicator {
public class TREnergyIndicator {

private final ItemStack stack;
private final double maxEnergy;
public TREnergyIndicator(ItemStack stack) {
this.stack = stack;
if (stack.getItem() instanceof EnergyHolder) {
maxEnergy = ((EnergyHolder)stack.getItem()).getMaxStoredPower();
} else {
maxEnergy = 0;
}
}

@Override
public String getDisplayValue() {
double energy = 0;
if (stack.getNbt() != null) {
energy = stack.getNbt().getDouble("energy");
}
if (ConfigurationHandler.getShowPercentValues() && maxEnergy > 0) {
return String.format("§o%.1f%%", energy / maxEnergy * 100);
}
if (energy > 10_000_000) {
return "§o"+((int)(energy/1000))+"M";
} else if (energy > 10_000) {
return "§o"+((int)(energy/1000))+"k";
} else {
return "§o"+(int)energy;
}
}

@Override
public int getDisplayColor() {
double energy = stack.getNbt().getDouble("energy");
if (energy > maxEnergy * 0.2) {
return color_green;
} else if (energy > maxEnergy * 0.1) {
return color_yellow;
} else {
return color_red;
}
}

@Override
public boolean isEmpty() {
return stack.isEmpty();
}

@Override
public boolean isItemStackDamageable() {
return true; // it is not, but we want to be displayed
}

@Override
public ItemStack getItemStack() {
return stack;
}
// private final ItemStack stack;
// private final double maxEnergy;
//
// public TREnergyIndicator(ItemStack stack) {
// this.stack = stack;
// if (stack.getItem() instanceof EnergyHolder) {
// maxEnergy = ((EnergyHolder)stack.getItem()).getMaxStoredPower();
// } else {
// maxEnergy = 0;
// }
// }
//
// @Override
// public String getDisplayValue() {
// double energy = 0;
// if (stack.getNbt() != null) {
// energy = stack.getNbt().getDouble("energy");
// }
// if (ConfigurationHandler.getShowPercentValues() && maxEnergy > 0) {
// return String.format("§o%.1f%%", energy / maxEnergy * 100);
// }
// if (energy > 10_000_000) {
// return "§o"+((int)(energy/1000))+"M";
// } else if (energy > 10_000) {
// return "§o"+((int)(energy/1000))+"k";
// } else {
// return "§o"+(int)energy;
// }
// }
//
// @Override
// public int getDisplayColor() {
// double energy = stack.getNbt().getDouble("energy");
// if (energy > maxEnergy * 0.2) {
// return color_green;
// } else if (energy > maxEnergy * 0.1) {
// return color_yellow;
// } else {
// return color_red;
// }
// }
//
// @Override
// public boolean isEmpty() {
// return stack.isEmpty();
// }
//
// @Override
// public boolean isItemStackDamageable() {
// return true; // it is not, but we want to be displayed
// }
//
// @Override
// public ItemStack getItemStack() {
// return stack;
// }
}

0 comments on commit 17c9298

Please sign in to comment.