diff --git a/src/main/java/WayofTime/bloodmagic/client/hud/Elements.java b/src/main/java/WayofTime/bloodmagic/client/hud/Elements.java new file mode 100644 index 00000000..6c507d1a --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/client/hud/Elements.java @@ -0,0 +1,101 @@ +package WayofTime.bloodmagic.client.hud; + +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.Sprite; +import WayofTime.bloodmagic.tile.TileAltar; +import WayofTime.bloodmagic.tile.TileIncenseAltar; +import WayofTime.bloodmagic.tile.TileInversionPillar; +import WayofTime.bloodmagic.util.helper.NumeralHelper; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.List; +import java.util.function.Function; + +public class Elements { + + public static void createHUDElements() { + new HUDElementHolding(); + new HUDElementDemonWillAura(); + // Blood Altar with Divination Sigil + new HUDElementCornerTile.DivinedView(TileAltar.class, true) { + @Override + protected void addInformation(List>> information) { + // Current tier + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), + altar -> NumeralHelper.toRoman(altar.getTier().toInt()) + )); + // Stored/Capacity + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), + altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity()) + )); + } + }; + // Blood Altar with Seers Sigil + new HUDElementCornerTile.DivinedView(TileAltar.class, false) { + @Override + protected void addInformation(List>> information) { + // Current tier + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), + altar -> NumeralHelper.toRoman(altar.getTier().toInt()) + )); + // Stored/Capacity + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), + altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity()) + )); + // Crafting progress/Crafting requirement + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 32, 46, 16, 16), + altar -> { + if (!altar.isActive()) + return "Inactive"; // FIXME localize + int progress = altar.getProgress(); + int totalLiquidRequired = altar.getLiquidRequired() * altar.getStackInSlot(0).getCount(); + return String.format("%d/%d", progress, totalLiquidRequired); + } + )); + // Consumption rate + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 48, 46, 16, 16), + altar -> String.valueOf((int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1))) + )); + // Total charge + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 64, 46, 16, 16), + altar -> String.valueOf(altar.getTotalCharge()) + )); + } + }; + // Incense Altar + new HUDElementCornerTile.DivinedView(TileIncenseAltar.class, true) { + @Override + protected void addInformation(List>> information) { + // Current tranquility + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 80, 46, 16, 16), + incense -> String.valueOf((int) ((100D * (int) (100 * incense.tranquility)) / 100D)) + )); + // Sacrifice bonus + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 96, 46, 16, 16), + incense -> String.valueOf((int) (100 * incense.incenseAddition)) + )); + } + }; + // Inversion Pillar + new HUDElementCornerTile.DivinedView(TileInversionPillar.class, true) { + @Override + protected void addInformation(List>> information) { + // Current inversion + information.add(Pair.of( + new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 112, 46, 16, 16), + pillar -> String.valueOf(((int) (10 * pillar.getCurrentInversion())) / 10D) + )); + } + }; + } +} diff --git a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementCornerTile.java b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementCornerTile.java index b84f1c5b..3ac6264c 100644 --- a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementCornerTile.java +++ b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementCornerTile.java @@ -47,11 +47,13 @@ public abstract class HUDElementCornerTile extends HUDElem } } - public static abstract class BloodAltar extends HUDElementCornerTile { + public static abstract class DivinedView extends HUDElementCornerTile { + private final Class tileClass; private final boolean simple; - public BloodAltar(boolean simple) { + public DivinedView(Class tileClass, boolean simple) { + this.tileClass = tileClass; this.simple = simple; } @@ -85,7 +87,7 @@ public abstract class HUDElementCornerTile extends HUDElem return false; TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(Minecraft.getMinecraft().objectMouseOver.getBlockPos()); - if (!(tile instanceof TileAltar)) + if (tile == null || !tileClass.isAssignableFrom(tile.getClass())) flag = false; return flag; diff --git a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java index 4ae09cac..3aa2be30 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.proxy; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.hud.Elements; import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.soul.DemonWillHolder; import WayofTime.bloodmagic.client.IMeshProvider; @@ -121,46 +122,7 @@ public class ClientProxy extends CommonProxy { @Override public void postInit() { - new HUDElementHolding(); - new HUDElementDemonWillAura(); - new HUDElementCornerTile.BloodAltar(true) { // Divination Sigil - @Override - protected void addInformation(List>> information) { - information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), altar -> NumeralHelper.toRoman(altar.getTier().toInt()))); - information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity()))); - } - }; - new HUDElementCornerTile.BloodAltar(false) { // Seer Sigil - @Override - protected void addInformation(List>> information) { - information.add(Pair.of( - new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), - altar -> NumeralHelper.toRoman(altar.getTier().toInt()) - )); - information.add(Pair.of( - new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), - altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity()) - )); - information.add(Pair.of( // Craft Progress - new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 32, 46, 16, 16), - altar -> { - if (!altar.isActive()) - return "Inactive"; // FIXME localize - int progress = altar.getProgress(); - int totalLiquidRequired = altar.getLiquidRequired() * altar.getStackInSlot(0).getCount(); - return String.format("%d/%d", progress, totalLiquidRequired); - } - )); - information.add(Pair.of( - new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 48, 46, 16, 16), - altar -> String.valueOf((int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1))) - )); - information.add(Pair.of( - new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 64, 46, 16, 16), - altar -> String.valueOf(altar.getTotalCharge()) - )); - } - }; + Elements.createHUDElements(); } @Override diff --git a/src/main/resources/assets/bloodmagic/textures/gui/widgets.png b/src/main/resources/assets/bloodmagic/textures/gui/widgets.png index 6d8d9cfe..4c80a03c 100644 Binary files a/src/main/resources/assets/bloodmagic/textures/gui/widgets.png and b/src/main/resources/assets/bloodmagic/textures/gui/widgets.png differ