diff --git a/src/main/java/wayoftime/bloodmagic/BloodMagic.java b/src/main/java/wayoftime/bloodmagic/BloodMagic.java index 42eab61d..5783c983 100644 --- a/src/main/java/wayoftime/bloodmagic/BloodMagic.java +++ b/src/main/java/wayoftime/bloodmagic/BloodMagic.java @@ -55,7 +55,6 @@ import wayoftime.bloodmagic.impl.BloodMagicAPI; import wayoftime.bloodmagic.impl.BloodMagicCorePlugin; import wayoftime.bloodmagic.network.BloodMagicPacketHandler; import wayoftime.bloodmagic.potion.BloodMagicPotions; -import wayoftime.bloodmagic.registry.ModTranquilityHandlers; import wayoftime.bloodmagic.ritual.RitualManager; import wayoftime.bloodmagic.structures.ModDungeons; import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber; @@ -133,7 +132,6 @@ public class BloodMagic ModLoadingContext context = ModLoadingContext.get(); context.registerConfig(ModConfig.Type.CLIENT, ConfigManager.CLIENT_SPEC); - ModTranquilityHandlers.init(); ModDungeons.init(); } diff --git a/src/main/java/wayoftime/bloodmagic/altar/AltarUtil.java b/src/main/java/wayoftime/bloodmagic/altar/AltarUtil.java index 68f26d49..b02d469a 100644 --- a/src/main/java/wayoftime/bloodmagic/altar/AltarUtil.java +++ b/src/main/java/wayoftime/bloodmagic/altar/AltarUtil.java @@ -12,7 +12,6 @@ import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import wayoftime.bloodmagic.api.tile.IAltarComponent; import wayoftime.bloodmagic.impl.BloodMagicAPI; import wayoftime.bloodmagic.common.block.BlockBloodRune; import wayoftime.bloodmagic.tile.TileAltar; @@ -35,10 +34,6 @@ public class AltarUtil BlockPos componentPos = pos.add(component.getOffset()); BlockState worldState = world.getBlockState(componentPos); - if (worldState.getBlock() instanceof IAltarComponent) - if (((IAltarComponent) worldState.getBlock()).getType(world, worldState, componentPos) == component.getComponent()) - continue; - if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR && !worldState.getMaterial().isLiquid()) continue; diff --git a/src/main/java/wayoftime/bloodmagic/altar/BloodAltar.java b/src/main/java/wayoftime/bloodmagic/altar/BloodAltar.java index 628d5286..b2a180c6 100644 --- a/src/main/java/wayoftime/bloodmagic/altar/BloodAltar.java +++ b/src/main/java/wayoftime/bloodmagic/altar/BloodAltar.java @@ -20,13 +20,13 @@ import net.minecraftforge.fluids.capability.templates.FluidTank; import net.minecraftforge.items.ItemHandlerHelper; import wayoftime.bloodmagic.api.event.BloodMagicCraftedEvent; import wayoftime.bloodmagic.impl.BloodMagicAPI; -import wayoftime.bloodmagic.api.recipe.RecipeBloodAltar; +import wayoftime.bloodmagic.recipe.RecipeBloodAltar; import wayoftime.bloodmagic.block.enums.BloodRuneType; import wayoftime.bloodmagic.common.block.BloodMagicBlocks; import wayoftime.bloodmagic.core.data.Binding; -import wayoftime.bloodmagic.api.item.IBindable; -import wayoftime.bloodmagic.orb.BloodOrb; -import wayoftime.bloodmagic.orb.IBloodOrb; +import wayoftime.bloodmagic.common.item.IBindable; +import wayoftime.bloodmagic.common.item.BloodOrb; +import wayoftime.bloodmagic.common.item.IBloodOrb; import wayoftime.bloodmagic.tile.TileAltar; import wayoftime.bloodmagic.util.Constants; import wayoftime.bloodmagic.util.helper.NetworkHelper; @@ -201,7 +201,7 @@ public class BloodAltar// implements IFluidHandler RecipeBloodAltar recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getBloodAltar(tileAltar.getWorld(), input); if (recipe != null) { - if (recipe.getMinimumTier().ordinal() <= altarTier.ordinal()) + if (recipe.getMinimumTier() <= altarTier.ordinal()) { this.isActive = true; this.recipe = recipe; diff --git a/src/main/java/wayoftime/bloodmagic/altar/ComponentType.java b/src/main/java/wayoftime/bloodmagic/altar/ComponentType.java index 6c9c6a5e..30cae9dc 100644 --- a/src/main/java/wayoftime/bloodmagic/altar/ComponentType.java +++ b/src/main/java/wayoftime/bloodmagic/altar/ComponentType.java @@ -9,7 +9,6 @@ public enum ComponentType { GLOWSTONE, BLOODSTONE, BEACON, BLOODRUNE, CRYSTAL, NOTAIR; - public static final ComponentType[] VALUES = values(); private static final String BASE = "chat.bloodmagic.altar.comp."; private String key; @@ -22,4 +21,17 @@ public enum ComponentType { return key; } + + public static ComponentType getType(String type) + { + for (ComponentType t : values()) + { + if (t.name().equalsIgnoreCase(type)) + { + return t; + } + } + + return null; + } } \ No newline at end of file diff --git a/src/main/java/wayoftime/bloodmagic/api/tile/IBloodAltar.java b/src/main/java/wayoftime/bloodmagic/altar/IBloodAltar.java similarity index 81% rename from src/main/java/wayoftime/bloodmagic/api/tile/IBloodAltar.java rename to src/main/java/wayoftime/bloodmagic/altar/IBloodAltar.java index 1d212292..08f8253c 100644 --- a/src/main/java/wayoftime/bloodmagic/api/tile/IBloodAltar.java +++ b/src/main/java/wayoftime/bloodmagic/altar/IBloodAltar.java @@ -1,14 +1,18 @@ -package wayoftime.bloodmagic.api.tile; - -import wayoftime.bloodmagic.altar.AltarTier; +package wayoftime.bloodmagic.altar; +/** + * Any Tile that implements this will be considered to be a Blood Altar + */ public interface IBloodAltar { int getCapacity(); int getCurrentBlood(); - AltarTier getTier(); + /** + * @return - The actual human-readable tier (ordinal + 1) of the altar + */ + int getTier(); int getProgress(); diff --git a/src/main/java/wayoftime/bloodmagic/api/tile/IBloodRune.java b/src/main/java/wayoftime/bloodmagic/altar/IBloodRune.java similarity index 61% rename from src/main/java/wayoftime/bloodmagic/api/tile/IBloodRune.java rename to src/main/java/wayoftime/bloodmagic/altar/IBloodRune.java index 95c6d207..e5cde2ba 100644 --- a/src/main/java/wayoftime/bloodmagic/api/tile/IBloodRune.java +++ b/src/main/java/wayoftime/bloodmagic/altar/IBloodRune.java @@ -1,4 +1,4 @@ -package wayoftime.bloodmagic.api.tile; +package wayoftime.bloodmagic.altar; import javax.annotation.Nullable; @@ -7,10 +7,10 @@ import net.minecraft.world.World; import wayoftime.bloodmagic.block.enums.BloodRuneType; /** - * Any block that implements this interface wil be considered as Blood Runes for the Blood Altar + * Any Block that implements this interface wil be considered as Blood Runes for the Blood Altar */ public interface IBloodRune { @Nullable - BloodRuneType getBloodRune(World world, BlockPos pos); + BloodRuneType getBloodRune(World world, BlockPos pos); } diff --git a/src/main/java/wayoftime/bloodmagic/api/IBloodMagicAPI.java b/src/main/java/wayoftime/bloodmagic/api/IBloodMagicAPI.java index d9ea2988..f252309d 100644 --- a/src/main/java/wayoftime/bloodmagic/api/IBloodMagicAPI.java +++ b/src/main/java/wayoftime/bloodmagic/api/IBloodMagicAPI.java @@ -3,6 +3,11 @@ package wayoftime.bloodmagic.api; import javax.annotation.Nonnull; import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.LazyValue; +import org.apache.logging.log4j.LogManager; + +import java.util.function.Predicate; /** * The main interface between a plugin and Blood Magic's internals. @@ -11,12 +16,22 @@ import net.minecraft.block.BlockState; * Magic. More advanced integration is out of the scope of this API and are * considered "addons". * - * To get an instance of this without actually creating an - * {@link IBloodMagicPlugin}, use {@link BloodMagicPlugin.Inject}. + * Use INSTANCE to get an instance of the API without actually implementing anything */ public interface IBloodMagicAPI { - + LazyValue INSTANCE = new LazyValue<>(() -> + { + try + { + return (IBloodMagicAPI) Class.forName("wayoftime.bloodmagic.impl.BloodMagicAPI").getDeclaredField("INSTANCE").get(null); + } + catch (ReflectiveOperationException e) + { + LogManager.getLogger().warn("Unable to find BloodMagicAPI, using a dummy instance instead..."); + return new IBloodMagicAPI() {}; + } + }); // /** // * Retrieves the instance of the blacklist. // * @@ -25,24 +40,19 @@ public interface IBloodMagicAPI // @Nonnull // IBloodMagicBlacklist getBlacklist(); - /** - * Retrieves the instance of the recipe registrar. - * - * @return the active {@link IBloodMagicRecipeRegistrar} instance - */ - @Nonnull - IBloodMagicRecipeRegistrar getRecipeRegistrar(); - /** * Retrieves the instance of the value manager. * * @return the active {@link IBloodMagicValueManager} instance */ @Nonnull - IBloodMagicValueManager getValueManager(); + default IBloodMagicValueManager getValueManager() + { + return new IBloodMagicValueManager() {}; + } /** - * Registers an {@link IBlockState} as a given component for the Blood Altar. + * Registers a {@link BlockState} as a given component for the Blood Altar. *

* Valid component types: *