Main hand on armor status
This commit is contained in:
@@ -14,22 +14,31 @@ import net.minecraft.item.Items;
|
|||||||
|
|
||||||
public class ArmorDisplay extends Module implements HudMod {
|
public class ArmorDisplay extends Module implements HudMod {
|
||||||
private static Property<Boolean> enabled = Property.bool(false);
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
private static ModDimensions dimensions = new ModDimensions(40, 60);
|
private static ModDimensions dimensions = new ModDimensions(40, 75);
|
||||||
|
private static Property<Boolean> useMainHand = Property.bool(false);
|
||||||
|
|
||||||
public ArmorDisplay() {
|
public ArmorDisplay() {
|
||||||
super(new ModuleDetails("Armor Display", "armor")
|
super(new ModuleDetails("Armor Display", "armor")
|
||||||
.description("Displays armor durability")
|
.description("Displays armor durability")
|
||||||
.version("v0.1.0")
|
.version("v0.1.0")
|
||||||
.tags("Utility"),
|
.tags("Utility"),
|
||||||
enabled.named("Enabled"),
|
enabled.named("Enabled"),
|
||||||
dimensions.prop());
|
useMainHand.named("Use Main Hand"),
|
||||||
|
dimensions.prop());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderArmor(RenderScope scope, ItemStack helmet, ItemStack chestplate, ItemStack leggings, ItemStack boots) {
|
public void renderArmor(RenderScope scope, ItemStack mainHand, ItemStack helmet, ItemStack chestplate,
|
||||||
|
ItemStack leggings, ItemStack boots) {
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
|
if (useMainHand.value && !mainHand.isEmpty()) {
|
||||||
|
scope.drawItem(mainHand, 0, 15 * row);
|
||||||
|
renderHealth(scope, row, mainHand.getMaxDamage(), mainHand.getDamage());
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!helmet.isEmpty()) {
|
if (!helmet.isEmpty()) {
|
||||||
scope.drawItem(helmet, 0, 0);
|
scope.drawItem(helmet, 0, 15 * row);
|
||||||
renderHealth(scope, row, helmet.getMaxDamage(), helmet.getDamage());
|
renderHealth(scope, row, helmet.getMaxDamage(), helmet.getDamage());
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
@@ -53,23 +62,27 @@ public class ArmorDisplay extends Module implements HudMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void renderHealth(RenderScope scope, int i, int max_damage, int damage) {
|
public void renderHealth(RenderScope scope, int i, int max_damage, int damage) {
|
||||||
if (max_damage > 0 ) {
|
if (max_damage > 0) {
|
||||||
scope.drawText(0.5f, "" + (max_damage - damage), 17, (15 * i) + 3, dimensions.font.value, dimensions.fgColor.value);
|
scope.drawText(0.5f, "" + (max_damage - damage), 17, (15 * i) + 3, dimensions.font.value,
|
||||||
|
dimensions.fgColor.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderHud(RenderScope scope) {
|
public void renderHud(RenderScope scope) {
|
||||||
renderArmor(scope,
|
renderArmor(scope,
|
||||||
SaturnClient.client.player.getEquippedStack(EquipmentSlot.HEAD),
|
SaturnClient.client.player.getEquippedStack(EquipmentSlot.MAINHAND),
|
||||||
SaturnClient.client.player.getEquippedStack(EquipmentSlot.CHEST),
|
SaturnClient.client.player.getEquippedStack(EquipmentSlot.HEAD),
|
||||||
SaturnClient.client.player.getEquippedStack(EquipmentSlot.LEGS),
|
SaturnClient.client.player.getEquippedStack(EquipmentSlot.CHEST),
|
||||||
SaturnClient.client.player.getEquippedStack(EquipmentSlot.FEET));
|
SaturnClient.client.player.getEquippedStack(EquipmentSlot.LEGS),
|
||||||
|
SaturnClient.client.player.getEquippedStack(EquipmentSlot.FEET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderDummy(RenderScope scope) {
|
public void renderDummy(RenderScope scope) {
|
||||||
renderArmor(scope, new ItemStack(Items.DIAMOND_HELMET), new ItemStack(Items.DIAMOND_CHESTPLATE), new ItemStack(Items.DIAMOND_LEGGINGS), new ItemStack(Items.DIAMOND_BOOTS));
|
renderArmor(scope, new ItemStack(Items.DIAMOND_SWORD), new ItemStack(Items.DIAMOND_HELMET),
|
||||||
|
new ItemStack(Items.DIAMOND_CHESTPLATE),
|
||||||
|
new ItemStack(Items.DIAMOND_LEGGINGS), new ItemStack(Items.DIAMOND_BOOTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user