Finished implementation of Incense Altar and associated blocks.
Also added the recipe for the Ritual Tinkerer, as well as the finalized book entry for the Incense Altar.
This commit is contained in:
parent
7634404dac
commit
cb2db9bc50
108 changed files with 2197 additions and 81 deletions
|
@ -28,6 +28,7 @@ import wayoftime.bloodmagic.client.screens.ScreenAlchemyTable;
|
|||
import wayoftime.bloodmagic.client.screens.ScreenSoulForge;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.common.item.ItemSacrificialDagger;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilToggleable;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSentientSword;
|
||||
import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes;
|
||||
|
@ -79,6 +80,7 @@ public class ClientEvents
|
|||
registerMultiWillTool(BloodMagicItems.LESSER_GEM.get());
|
||||
registerMultiWillTool(BloodMagicItems.COMMON_GEM.get());
|
||||
registerMultiWillTool(BloodMagicItems.GREATER_GEM.get());
|
||||
registerSacrificialKnife(BloodMagicItems.SACRIFICIAL_DAGGER.get());
|
||||
|
||||
ItemModelsProperties.registerProperty(BloodMagicItems.SENTIENT_SWORD.get(), BloodMagic.rl("active"), new IItemPropertyGetter()
|
||||
{
|
||||
|
@ -129,4 +131,21 @@ public class ClientEvents
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerSacrificialKnife(Item item)
|
||||
{
|
||||
ItemModelsProperties.registerProperty(item, BloodMagic.rl("incense"), new IItemPropertyGetter()
|
||||
{
|
||||
@Override
|
||||
public float call(ItemStack stack, ClientWorld world, LivingEntity entity)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemSacrificialDagger)
|
||||
{
|
||||
return ((ItemSacrificialDagger) item).canUseForSacrifice(stack) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
57
src/main/java/wayoftime/bloodmagic/client/Sprite.java
Normal file
57
src/main/java/wayoftime/bloodmagic/client/Sprite.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package wayoftime.bloodmagic.client;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class Sprite
|
||||
{
|
||||
|
||||
private final ResourceLocation textureLocation;
|
||||
private final int textureX;
|
||||
private final int textureY;
|
||||
private final int textureWidth;
|
||||
private final int textureHeight;
|
||||
|
||||
public Sprite(ResourceLocation textureLocation, int textureX, int textureY, int textureWidth, int textureHeight)
|
||||
{
|
||||
this.textureLocation = textureLocation;
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
this.textureWidth = textureWidth;
|
||||
this.textureHeight = textureHeight;
|
||||
}
|
||||
|
||||
public ResourceLocation getTextureLocation()
|
||||
{
|
||||
return textureLocation;
|
||||
}
|
||||
|
||||
public int getTextureX()
|
||||
{
|
||||
return textureX;
|
||||
}
|
||||
|
||||
public int getTextureY()
|
||||
{
|
||||
return textureY;
|
||||
}
|
||||
|
||||
public int getTextureWidth()
|
||||
{
|
||||
return textureWidth;
|
||||
}
|
||||
|
||||
public int getTextureHeight()
|
||||
{
|
||||
return textureHeight;
|
||||
}
|
||||
|
||||
public void draw(MatrixStack matrixStack, int x, int y)
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(getTextureLocation());
|
||||
AbstractGui.blit(matrixStack, x, y, 0, getTextureX(), getTextureY(), getTextureWidth(), getTextureHeight(), 256, 256);
|
||||
}
|
||||
}
|
|
@ -1,15 +1,90 @@
|
|||
package wayoftime.bloodmagic.client.hud;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Vector2f;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.ConfigManager;
|
||||
import wayoftime.bloodmagic.client.Sprite;
|
||||
import wayoftime.bloodmagic.client.hud.element.ElementDemonAura;
|
||||
import wayoftime.bloodmagic.client.hud.element.ElementDivinedInformation;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
import wayoftime.bloodmagic.tile.TileIncenseAltar;
|
||||
import wayoftime.bloodmagic.util.helper.NumeralHelper;
|
||||
|
||||
public class Elements
|
||||
{
|
||||
public static void registerElements()
|
||||
{
|
||||
ElementRegistry.registerHandler(new ResourceLocation(BloodMagic.MODID, "demon_will_aura"), new ElementDemonAura(), new Vector2f(ConfigManager.CLIENT.demonWillGaugeX.get().floatValue(), ConfigManager.CLIENT.demonWillGaugeY.get().floatValue()));
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package wayoftime.bloodmagic.client.hud.element;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Hand;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
||||
public abstract class ElementDivinedInformation<T extends TileEntity> extends ElementTileInformation<T>
|
||||
{
|
||||
|
||||
private final boolean simple;
|
||||
|
||||
public ElementDivinedInformation(int lines, boolean simple, Class<T> tileClass)
|
||||
{
|
||||
super(100, lines, tileClass);
|
||||
this.simple = simple;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(Minecraft minecraft)
|
||||
{
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
ItemStack sigilStack = player.getHeldItem(Hand.MAIN_HAND);
|
||||
boolean flag = false;
|
||||
if (simple)
|
||||
{
|
||||
if (sigilStack.getItem() == BloodMagicItems.DIVINATION_SIGIL.get() || sigilStack.getItem() == BloodMagicItems.SEER_SIGIL.get())
|
||||
flag = true;
|
||||
else
|
||||
flag = isFlagSigilHolding(sigilStack, true);
|
||||
|
||||
// if (!flag)
|
||||
// {
|
||||
// sigilStack = player.getHeldItem(Hand.OFF_HAND);
|
||||
// if (sigilStack.getItem() == RegistrarBloodMagicItems.SIGIL_DIVINATION || sigilStack.getItem() == RegistrarBloodMagicItems.SIGIL_SEER)
|
||||
// flag = true;
|
||||
// else
|
||||
// flag = isFlagSigilHolding(sigilStack, true);
|
||||
// }
|
||||
|
||||
} else
|
||||
{
|
||||
if (sigilStack.getItem() == BloodMagicItems.SEER_SIGIL.get())
|
||||
flag = true;
|
||||
else
|
||||
flag = isFlagSigilHolding(sigilStack, false);
|
||||
//
|
||||
// if (!flag)
|
||||
// {
|
||||
// sigilStack = player.getHeldItem(Hand.OFF_HAND);
|
||||
// if (sigilStack.getItem() == RegistrarBloodMagicItems.SIGIL_SEER)
|
||||
// flag = true;
|
||||
// else
|
||||
// flag = isFlagSigilHolding(sigilStack, false);
|
||||
// }
|
||||
}
|
||||
|
||||
return super.shouldRender(minecraft) && flag;
|
||||
}
|
||||
|
||||
private boolean isFlagSigilHolding(ItemStack sigilStack, boolean simple)
|
||||
{
|
||||
// if (sigilStack.getItem() instanceof ItemSigilHolding)
|
||||
// {
|
||||
// List<ItemStack> internalInv = ItemSigilHolding.getInternalInventory(sigilStack);
|
||||
// int currentSlot = ItemSigilHolding.getCurrentItemOrdinal(sigilStack);
|
||||
// if (internalInv != null && !internalInv.get(currentSlot).isEmpty())
|
||||
// {
|
||||
// return (internalInv.get(currentSlot).getItem() == RegistrarBloodMagicItems.SIGIL_SEER && !simple) || (internalInv.get(currentSlot).getItem() == RegistrarBloodMagicItems.SIGIL_DIVINATION && simple);
|
||||
// }
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package wayoftime.bloodmagic.client.hud.element;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import wayoftime.bloodmagic.client.Sprite;
|
||||
|
||||
public abstract class ElementTileInformation<T extends TileEntity> extends HUDElement
|
||||
{
|
||||
|
||||
protected final Class<T> tileClass;
|
||||
private final List<Pair<Sprite, Function<T, String>>> information;
|
||||
|
||||
public ElementTileInformation(int width, int lines, Class<T> tileClass)
|
||||
{
|
||||
super(width, 18 * lines - 2);
|
||||
|
||||
this.tileClass = tileClass;
|
||||
this.information = Lists.newArrayList();
|
||||
gatherInformation(information::add);
|
||||
}
|
||||
|
||||
public abstract void gatherInformation(Consumer<Pair<Sprite, Function<T, String>>> information);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void draw(MatrixStack matrixStack, float partialTicks, int drawX, int drawY)
|
||||
{
|
||||
RayTraceResult trace = Minecraft.getInstance().objectMouseOver;
|
||||
if (trace == null || trace.getType() != RayTraceResult.Type.BLOCK)
|
||||
return;
|
||||
|
||||
T tile = (T) Minecraft.getInstance().world.getTileEntity(((BlockRayTraceResult) trace).getPos());
|
||||
|
||||
int yOffset = 0;
|
||||
for (Pair<Sprite, Function<T, String>> sprite : information)
|
||||
{
|
||||
sprite.getLeft().draw(matrixStack, drawX, drawY + yOffset);
|
||||
int textY = drawY + yOffset + (sprite.getLeft().getTextureHeight() / 4);
|
||||
Minecraft.getInstance().fontRenderer.drawStringWithShadow(matrixStack, (tile != null && tile.getClass() == tileClass)
|
||||
? sprite.getRight().apply(tile)
|
||||
: "?", drawX + sprite.getLeft().getTextureWidth() + 2, textY, Color.WHITE.getRGB());
|
||||
yOffset += sprite.getLeft().getTextureHeight() + 2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(Minecraft minecraft)
|
||||
{
|
||||
RayTraceResult trace = Minecraft.getInstance().objectMouseOver;
|
||||
if (trace == null || trace.getType() != RayTraceResult.Type.BLOCK)
|
||||
return false;
|
||||
|
||||
TileEntity tile = Minecraft.getInstance().world.getTileEntity(((BlockRayTraceResult) trace).getPos());
|
||||
if (tile == null || !tileClass.isAssignableFrom(tile.getClass()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue