2020-11-12 02:15:58 +00:00
|
|
|
package wayoftime.bloodmagic.client.hud;
|
|
|
|
|
2020-11-14 00:44:57 +00:00
|
|
|
import java.util.function.Consumer;
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
|
|
|
|
import net.minecraft.client.resources.I18n;
|
2020-11-12 02:15:58 +00:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraft.util.math.vector.Vector2f;
|
|
|
|
import wayoftime.bloodmagic.BloodMagic;
|
2020-11-12 18:16:44 +00:00
|
|
|
import wayoftime.bloodmagic.ConfigManager;
|
2020-11-14 00:44:57 +00:00
|
|
|
import wayoftime.bloodmagic.client.Sprite;
|
2020-11-12 02:15:58 +00:00
|
|
|
import wayoftime.bloodmagic.client.hud.element.ElementDemonAura;
|
2020-11-14 00:44:57 +00:00
|
|
|
import wayoftime.bloodmagic.client.hud.element.ElementDivinedInformation;
|
|
|
|
import wayoftime.bloodmagic.tile.TileAltar;
|
|
|
|
import wayoftime.bloodmagic.tile.TileIncenseAltar;
|
|
|
|
import wayoftime.bloodmagic.util.helper.NumeralHelper;
|
2020-11-12 02:15:58 +00:00
|
|
|
|
|
|
|
public class Elements
|
|
|
|
{
|
|
|
|
public static void registerElements()
|
|
|
|
{
|
2020-11-12 18:16:44 +00:00
|
|
|
ElementRegistry.registerHandler(new ResourceLocation(BloodMagic.MODID, "demon_will_aura"), new ElementDemonAura(), new Vector2f(ConfigManager.CLIENT.demonWillGaugeX.get().floatValue(), ConfigManager.CLIENT.demonWillGaugeY.get().floatValue()));
|
2020-11-14 00:44:57 +00:00
|
|
|
|
|
|
|
ElementRegistry.registerHandler(BloodMagic.rl("blood_altar"), new ElementDivinedInformation<TileAltar>(2, true, TileAltar.class)
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void gatherInformation(Consumer<Pair<Sprite, Function<TileAltar, String>>> information)
|
|
|
|
{
|
|
|
|
// Current tier
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), altar -> altar == null
|
|
|
|
? "IV"
|
|
|
|
: NumeralHelper.toRoman(altar.getTier().toInt())));
|
|
|
|
// Stored/Capacity
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), altar -> String.format("%d/%d", altar == null
|
|
|
|
? 0
|
|
|
|
: altar.getCurrentBlood(), altar == null ? 10000 : altar.getCapacity())));
|
|
|
|
}
|
|
|
|
}, new Vector2f(0.01F, 0.01F));
|
|
|
|
|
|
|
|
ElementRegistry.registerHandler(new ResourceLocation(BloodMagic.MODID, "blood_altar_adv"), new ElementDivinedInformation<TileAltar>(5, false, TileAltar.class)
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void gatherInformation(Consumer<Pair<Sprite, Function<TileAltar, String>>> information)
|
|
|
|
{
|
|
|
|
// Current tier
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), altar -> altar == null
|
|
|
|
? "IV"
|
|
|
|
: NumeralHelper.toRoman(altar.getTier().toInt())));
|
|
|
|
// Stored/Capacity
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), altar -> String.format("%d/%d", altar == null
|
|
|
|
? 0
|
|
|
|
: altar.getCurrentBlood(), altar == null ? 10000 : altar.getCapacity())));
|
|
|
|
// Crafting progress/Crafting requirement
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 32, 46, 16, 16), altar -> {
|
|
|
|
if (altar == null || !altar.isActive())
|
|
|
|
return I18n.format("hud.bloodmagic.inactive");
|
|
|
|
int progress = altar.getProgress();
|
|
|
|
int totalLiquidRequired = altar.getLiquidRequired() * altar.getStackInSlot(0).getCount();
|
|
|
|
return String.format("%d/%d", progress, totalLiquidRequired);
|
|
|
|
}));
|
|
|
|
// Consumption rate
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 48, 46, 16, 16), altar -> altar == null
|
|
|
|
? "0"
|
|
|
|
: String.valueOf((int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1)))));
|
|
|
|
// Total charge
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 64, 46, 16, 16), altar -> altar == null
|
|
|
|
? "0"
|
|
|
|
: String.valueOf(altar.getTotalCharge())));
|
|
|
|
}
|
|
|
|
}, new Vector2f(0.01F, 0.01F));
|
|
|
|
|
|
|
|
ElementRegistry.registerHandler(new ResourceLocation(BloodMagic.MODID, "incense_altar"), new ElementDivinedInformation<TileIncenseAltar>(2, true, TileIncenseAltar.class)
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void gatherInformation(Consumer<Pair<Sprite, Function<TileIncenseAltar, String>>> information)
|
|
|
|
{
|
|
|
|
// Current tranquility
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 80, 46, 16, 16), incense -> incense == null
|
|
|
|
? "0"
|
|
|
|
: String.valueOf((int) ((100D * (int) (100 * incense.tranquility)) / 100D))));
|
|
|
|
// Sacrifice bonus
|
|
|
|
information.accept(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 96, 46, 16, 16), incense -> incense == null
|
|
|
|
? "0"
|
|
|
|
: String.valueOf((int) (100 * incense.incenseAddition))));
|
|
|
|
}
|
|
|
|
}, new Vector2f(0.01F, 0.01F));
|
2020-11-12 02:15:58 +00:00
|
|
|
}
|
|
|
|
}
|