Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
189 changed files with 6092 additions and 4041 deletions
|
@ -17,177 +17,212 @@ import com.google.common.collect.HashBiMap;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AlchemyArrayRecipeRegistry {
|
||||
public class AlchemyArrayRecipeRegistry
|
||||
{
|
||||
|
||||
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
|
||||
@Getter
|
||||
private static BiMap<ItemStackWrapper, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||
@Getter
|
||||
private static BiMap<ItemStackWrapper, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
*
|
||||
* @param inputStack
|
||||
* - Input item that is used to change the Alchemy Circle into
|
||||
* the circle that you are making
|
||||
* @param catalystStack
|
||||
* - Catalyst item that, when right-clicked onto the array, will
|
||||
* cause an effect
|
||||
* @param arrayEffect
|
||||
* - The effect that will be activated once the array is
|
||||
* activated
|
||||
* @param circleRenderer
|
||||
* - Circle rendered when the array is passive - can be
|
||||
* substituted for a special renderer
|
||||
*/
|
||||
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null) {
|
||||
return; // Recipe already exists!
|
||||
} else {
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null) {
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
*
|
||||
* @param inputStack
|
||||
* - Input item that is used to change the Alchemy Circle into
|
||||
* the circle that you are making
|
||||
* @param catalystStack
|
||||
* - Catalyst item that, when right-clicked onto the array, will
|
||||
* cause an effect
|
||||
* @param arrayEffect
|
||||
* - The effect that will be activated once the array is
|
||||
* activated
|
||||
* @param circleRenderer
|
||||
* - Circle rendered when the array is passive - can be
|
||||
* substituted for a special renderer
|
||||
*/
|
||||
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null)
|
||||
{
|
||||
return; // Recipe already exists!
|
||||
} else
|
||||
{
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null)
|
||||
{
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (circleRenderer == null) {
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer));
|
||||
} else {
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
if (circleRenderer == null)
|
||||
{
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer));
|
||||
} else
|
||||
{
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), circleRenderer);
|
||||
}
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||
}
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||
}
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||
AlchemyCircleRenderer circleRenderer = null;
|
||||
if (arrayResource == null) {
|
||||
circleRenderer = defaultRenderer;
|
||||
} else {
|
||||
circleRenderer = new AlchemyCircleRenderer(arrayResource);
|
||||
}
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource)
|
||||
{
|
||||
AlchemyCircleRenderer circleRenderer = null;
|
||||
if (arrayResource == null)
|
||||
{
|
||||
circleRenderer = defaultRenderer;
|
||||
} else
|
||||
{
|
||||
circleRenderer = new AlchemyCircleRenderer(arrayResource);
|
||||
}
|
||||
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
|
||||
public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer) {
|
||||
if (circleRenderer == null) {
|
||||
return;
|
||||
}
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
if (circleRenderer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AlchemyArrayRecipe getRecipeForInput(ItemStack input) {
|
||||
return recipes.get(input);
|
||||
}
|
||||
public static AlchemyArrayRecipe getRecipeForInput(ItemStack input)
|
||||
{
|
||||
return recipes.get(input);
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack))) {
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack)))
|
||||
{
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
|
||||
return effect; // TODO: Decide if a copy should be returned.
|
||||
}
|
||||
}
|
||||
return effect; // TODO: Decide if a copy should be returned.
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
return arrayRecipe.circleRenderer;
|
||||
}
|
||||
}
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
return arrayRecipe.circleRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultRenderer;
|
||||
}
|
||||
return defaultRenderer;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AlchemyArrayRecipe {
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AlchemyArrayRecipe
|
||||
{
|
||||
|
||||
public AlchemyCircleRenderer circleRenderer;
|
||||
public final ItemStack inputStack;
|
||||
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
||||
public AlchemyCircleRenderer circleRenderer;
|
||||
public final ItemStack inputStack;
|
||||
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
||||
|
||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
this.inputStack = inputStack;
|
||||
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
|
||||
this.circleRenderer = circleRenderer;
|
||||
}
|
||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
this.inputStack = inputStack;
|
||||
|
||||
/**
|
||||
* Compares the inputed ItemStack to see if it matches with the recipe's
|
||||
* inputStack.
|
||||
*
|
||||
* @param comparedStack
|
||||
* @return - true if the ItemStack is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(ItemStack comparedStack) {
|
||||
if (comparedStack == null || this.inputStack == null)
|
||||
return false;
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
|
||||
return this.inputStack.isItemEqual(comparedStack);
|
||||
}
|
||||
this.circleRenderer = circleRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||
*
|
||||
* @param comparedStack
|
||||
* The catalyst that is being checked
|
||||
* @return
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
if (comparedStack == null && catalystStack == null) {
|
||||
return entry.getValue();
|
||||
}
|
||||
/**
|
||||
* Compares the inputed ItemStack to see if it matches with the recipe's
|
||||
* inputStack.
|
||||
*
|
||||
* @param comparedStack
|
||||
* @return - true if the ItemStack is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(ItemStack comparedStack)
|
||||
{
|
||||
if (comparedStack == null || this.inputStack == null)
|
||||
return false;
|
||||
|
||||
if (comparedStack == null || catalystStack == null) {
|
||||
continue;
|
||||
}
|
||||
return this.inputStack.isItemEqual(comparedStack);
|
||||
}
|
||||
|
||||
if (catalystStack.isItemEqual(comparedStack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||
*
|
||||
* @param comparedStack
|
||||
* The catalyst that is being checked
|
||||
* @return
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet())
|
||||
{
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
if (comparedStack == null && catalystStack == null)
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (comparedStack == null || catalystStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (catalystStack.isItemEqual(comparedStack))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,26 +11,29 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AltarRecipeRegistry {
|
||||
|
||||
public class AltarRecipeRegistry
|
||||
{
|
||||
@Getter
|
||||
private static BiMap<ItemStack, AltarRecipe> recipes = HashBiMap.create();
|
||||
|
||||
public static void registerRecipe(AltarRecipe recipe) {
|
||||
public static void registerRecipe(AltarRecipe recipe)
|
||||
{
|
||||
if (!recipes.containsValue(recipe))
|
||||
recipes.put(recipe.input, recipe);
|
||||
else
|
||||
BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> " );
|
||||
BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> ");
|
||||
}
|
||||
|
||||
public static AltarRecipe getRecipeForInput(ItemStack input) {
|
||||
public static AltarRecipe getRecipeForInput(ItemStack input)
|
||||
{
|
||||
return recipes.get(input);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AltarRecipe {
|
||||
public static class AltarRecipe
|
||||
{
|
||||
|
||||
public final int syphon, consumeRate, drainRate;
|
||||
public final boolean useTag;
|
||||
|
@ -38,18 +41,29 @@ public class AltarRecipeRegistry {
|
|||
public final EnumAltarTier minTier;
|
||||
|
||||
/**
|
||||
* Allows creation of a recipe for the {@link WayofTime.bloodmagic.block.BlockAltar} / {@link WayofTime.bloodmagic.tile.TileAltar}.
|
||||
* The output ItemStack is allowed to be null as some recipes do not contain an output. (Blood Orbs)
|
||||
*
|
||||
* @param input - The input ItemStack
|
||||
* @param output - The ItemStack obtained from the recipe
|
||||
* @param minTier - The minimum tier of Altar required
|
||||
* @param syphon - The amount of LP to syphon from the Altar
|
||||
* @param consumeRate - The rate at which LP is consumed during crafting
|
||||
* @param drainRate - The rate at which LP is drained during crafting
|
||||
* @param useTag -
|
||||
* Allows creation of a recipe for the
|
||||
* {@link WayofTime.bloodmagic.block.BlockAltar} /
|
||||
* {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is
|
||||
* allowed to be null as some recipes do not contain an output. (Blood
|
||||
* Orbs)
|
||||
*
|
||||
* @param input
|
||||
* - The input ItemStack
|
||||
* @param output
|
||||
* - The ItemStack obtained from the recipe
|
||||
* @param minTier
|
||||
* - The minimum tier of Altar required
|
||||
* @param syphon
|
||||
* - The amount of LP to syphon from the Altar
|
||||
* @param consumeRate
|
||||
* - The rate at which LP is consumed during crafting
|
||||
* @param drainRate
|
||||
* - The rate at which LP is drained during crafting
|
||||
* @param useTag
|
||||
* -
|
||||
*/
|
||||
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
|
||||
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag)
|
||||
{
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minTier = minTier;
|
||||
|
@ -59,19 +73,27 @@ public class AltarRecipeRegistry {
|
|||
this.useTag = useTag;
|
||||
}
|
||||
|
||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate)
|
||||
{
|
||||
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
||||
}
|
||||
|
||||
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) {
|
||||
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate)
|
||||
{
|
||||
this(input, null, minTier, 0, consumeRate, drainRate);
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) {
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck)
|
||||
{
|
||||
if (comparedStack == null || this.input == null)
|
||||
return false;
|
||||
|
||||
return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true);
|
||||
return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// &&
|
||||
// (this.useTag
|
||||
// ?
|
||||
// this.areRequiredTagsEqual(comparedStack)
|
||||
// :
|
||||
// true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,24 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImperfectRitualRegistry {
|
||||
public class ImperfectRitualRegistry
|
||||
{
|
||||
|
||||
public static final Map<ImperfectRitual, Boolean> enabledRituals = new HashMap<ImperfectRitual, Boolean>();
|
||||
private static final BiMap<String, ImperfectRitual> registry = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param imperfectRitual - The imperfect ritual to register.
|
||||
* @param id - The ID for the imperfect ritual. Cannot be duplicated.
|
||||
*
|
||||
* @param imperfectRitual
|
||||
* - The imperfect ritual to register.
|
||||
* @param id
|
||||
* - The ID for the imperfect ritual. Cannot be duplicated.
|
||||
*/
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id) {
|
||||
if (imperfectRitual != null) {
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id)
|
||||
{
|
||||
if (imperfectRitual != null)
|
||||
{
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.getLogger().error("Duplicate imperfect ritual id: %s", id);
|
||||
else
|
||||
|
@ -30,11 +35,13 @@ public class ImperfectRitualRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual) {
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
registerRitual(imperfectRitual, imperfectRitual.getName());
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack) {
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack)
|
||||
{
|
||||
for (ImperfectRitual imperfectRitual : getRegistry().values())
|
||||
if (imperfectRitual.getRequiredBlock().equals(blockStack))
|
||||
return imperfectRitual;
|
||||
|
@ -42,44 +49,55 @@ public class ImperfectRitualRegistry {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForId(String id) {
|
||||
public static ImperfectRitual getRitualForId(String id)
|
||||
{
|
||||
return registry.get(id);
|
||||
}
|
||||
|
||||
public static String getIdForRitual(ImperfectRitual imperfectRitual) {
|
||||
public static String getIdForRitual(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
return registry.inverse().get(imperfectRitual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty() {
|
||||
public static boolean isMapEmpty()
|
||||
{
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize() {
|
||||
public static int getMapSize()
|
||||
{
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual) {
|
||||
try {
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
try
|
||||
{
|
||||
return enabledRituals.get(imperfectRitual);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
BloodMagicAPI.getLogger().error("Invalid Imperfect Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<String, ImperfectRitual> getRegistry() {
|
||||
public static BiMap<String, ImperfectRitual> getRegistry()
|
||||
{
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap() {
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap()
|
||||
{
|
||||
return HashBiMap.create(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
public static ArrayList<String> getIds()
|
||||
{
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
||||
public static ArrayList<ImperfectRitual> getRituals() {
|
||||
public static ArrayList<ImperfectRitual> getRituals()
|
||||
{
|
||||
return new ArrayList<ImperfectRitual>(registry.values());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,17 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is only for those who wish to add a basic {@link BloodOrb}. If you need custom handling,
|
||||
* you will need your own item class.
|
||||
* This is only for those who wish to add a basic {@link BloodOrb}. If you need
|
||||
* custom handling, you will need your own item class.
|
||||
*/
|
||||
public class OrbRegistry {
|
||||
public class OrbRegistry
|
||||
{
|
||||
|
||||
@Getter
|
||||
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
||||
|
||||
public static void registerOrb(BloodOrb orb) {
|
||||
public static void registerOrb(BloodOrb orb)
|
||||
{
|
||||
if (!orbs.contains(orb))
|
||||
orbs.add(orb);
|
||||
else
|
||||
|
@ -30,30 +32,36 @@ public class OrbRegistry {
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerOrbTexture(BloodOrb orb, String resourceLocation) {
|
||||
public static void registerOrbTexture(BloodOrb orb, String resourceLocation)
|
||||
{
|
||||
int meta = getIndexOf(orb);
|
||||
|
||||
ModelBakery.addVariantName(BloodMagicAPI.getItem(BloodMagicAPI.ORB), resourceLocation);
|
||||
ModelLoader.setCustomModelResourceLocation(BloodMagicAPI.getItem(BloodMagicAPI.ORB), meta, new ModelResourceLocation(resourceLocation, "inventory"));
|
||||
}
|
||||
|
||||
public static BloodOrb getOrb(int index) {
|
||||
public static BloodOrb getOrb(int index)
|
||||
{
|
||||
return orbs.get(index);
|
||||
}
|
||||
|
||||
public static int getIndexOf(BloodOrb orb) {
|
||||
public static int getIndexOf(BloodOrb orb)
|
||||
{
|
||||
return orbs.indexOf(orb);
|
||||
}
|
||||
|
||||
public static boolean isEmpty() {
|
||||
public static boolean isEmpty()
|
||||
{
|
||||
return orbs.isEmpty();
|
||||
}
|
||||
|
||||
public static int getSize() {
|
||||
public static int getSize()
|
||||
{
|
||||
return orbs.size();
|
||||
}
|
||||
|
||||
public static ItemStack getOrbStack(BloodOrb orb) {
|
||||
public static ItemStack getOrbStack(BloodOrb orb)
|
||||
{
|
||||
return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.ORB), 1, getIndexOf(orb));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,72 +10,91 @@ import WayofTime.bloodmagic.api.ritual.Ritual;
|
|||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
public class RitualRegistry {
|
||||
public class RitualRegistry
|
||||
{
|
||||
|
||||
public static final Map<Ritual, Boolean> enabledRituals = new HashMap<Ritual, Boolean>();
|
||||
private static final BiMap<String, Ritual> registry = HashBiMap.create();
|
||||
// Ordered list for actions that depend on the order that the rituals were registered in
|
||||
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
|
||||
// Ordered list for actions that depend on the order that the rituals were
|
||||
// registered in
|
||||
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param ritual - The ritual to register.
|
||||
* @param id - The ID for the ritual. Cannot be duplicated.
|
||||
*
|
||||
* @param ritual
|
||||
* - The ritual to register.
|
||||
* @param id
|
||||
* - The ID for the ritual. Cannot be duplicated.
|
||||
*/
|
||||
public static void registerRitual(Ritual ritual, String id) {
|
||||
if (ritual != null) {
|
||||
public static void registerRitual(Ritual ritual, String id)
|
||||
{
|
||||
if (ritual != null)
|
||||
{
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.getLogger().error("Duplicate ritual id: %s", id);
|
||||
else {
|
||||
else
|
||||
{
|
||||
registry.put(id, ritual);
|
||||
orderedIdList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Ritual getRitualForId(String id) {
|
||||
public static Ritual getRitualForId(String id)
|
||||
{
|
||||
return registry.get(id);
|
||||
}
|
||||
|
||||
public static String getIdForRitual(Ritual ritual) {
|
||||
public static String getIdForRitual(Ritual ritual)
|
||||
{
|
||||
return registry.inverse().get(ritual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty() {
|
||||
public static boolean isMapEmpty()
|
||||
{
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize() {
|
||||
public static int getMapSize()
|
||||
{
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(Ritual ritual) {
|
||||
try {
|
||||
public static boolean ritualEnabled(Ritual ritual)
|
||||
{
|
||||
try
|
||||
{
|
||||
return enabledRituals.get(ritual);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
BloodMagicAPI.getLogger().error("Invalid Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<String, Ritual> getRegistry() {
|
||||
public static BiMap<String, Ritual> getRegistry()
|
||||
{
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static Map<Ritual, Boolean> getEnabledMap() {
|
||||
public static Map<Ritual, Boolean> getEnabledMap()
|
||||
{
|
||||
return new HashMap<Ritual, Boolean>(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
public static ArrayList<String> getIds()
|
||||
{
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
||||
public static ArrayList<String> getOrderedIds() {
|
||||
return orderedIdList;
|
||||
|
||||
public static ArrayList<String> getOrderedIds()
|
||||
{
|
||||
return orderedIdList;
|
||||
}
|
||||
|
||||
public static ArrayList<Ritual> getRituals() {
|
||||
public static ArrayList<Ritual> getRituals()
|
||||
{
|
||||
return new ArrayList<Ritual>(registry.values());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue