Initial stab at API structuring (#1711)

This commit is contained in:
Arcaratus 2020-11-18 13:53:20 -05:00 committed by GitHub
parent 546215ab37
commit 1ae356c886
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 149 additions and 120 deletions

View file

@ -1,102 +0,0 @@
package wayoftime.bloodmagic.api.impl;
import java.util.List;
import javax.annotation.Nonnull;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.block.BlockState;
import wayoftime.bloodmagic.altar.ComponentType;
import wayoftime.bloodmagic.api.IBloodMagicAPI;
import wayoftime.bloodmagic.util.BMLog;
public class BloodMagicAPI implements IBloodMagicAPI
{
public static final BloodMagicAPI INSTANCE = new BloodMagicAPI();
// private final BloodMagicBlacklist blacklist;
private final BloodMagicRecipeRegistrar recipeRegistrar;
private final BloodMagicValueManager valueManager;
private final Multimap<ComponentType, BlockState> altarComponents;
public BloodMagicAPI()
{
// this.blacklist = new BloodMagicBlacklist();
this.recipeRegistrar = new BloodMagicRecipeRegistrar();
this.valueManager = new BloodMagicValueManager();
this.altarComponents = ArrayListMultimap.create();
}
// @Nonnull
// @Override
// public BloodMagicBlacklist getBlacklist()
// {
// return blacklist;
// }
//
@Nonnull
@Override
public BloodMagicRecipeRegistrar getRecipeRegistrar()
{
return recipeRegistrar;
}
//
@Nonnull
@Override
public BloodMagicValueManager getValueManager()
{
return valueManager;
}
@Override
public void registerAltarComponent(@Nonnull BlockState state, @Nonnull String componentType)
{
ComponentType component = null;
for (ComponentType type : ComponentType.VALUES)
{
if (type.name().equalsIgnoreCase(componentType))
{
component = type;
break;
}
}
if (component != null)
{
BMLog.API_VERBOSE.info("Registered {} as a {} altar component.", state, componentType);
altarComponents.put(component, state);
} else
BMLog.API.warn("Invalid Altar component type: {}.", componentType);
}
@Override
public void unregisterAltarComponent(@Nonnull BlockState state, @Nonnull String componentType)
{
ComponentType component = null;
for (ComponentType type : ComponentType.VALUES)
{
if (type.name().equalsIgnoreCase(componentType))
{
component = type;
break;
}
}
if (component != null)
{
BMLog.API_VERBOSE.info("Unregistered {} from being a {} altar component.", state, componentType);
altarComponents.remove(component, state);
} else
BMLog.API.warn("Invalid Altar component type: {}.", componentType);
}
@Nonnull
public List<BlockState> getComponentStates(ComponentType component)
{
return (List<BlockState>) altarComponents.get(component);
}
}

View file

@ -1,47 +0,0 @@
package wayoftime.bloodmagic.api.impl;
import net.minecraft.block.Blocks;
import wayoftime.bloodmagic.altar.ComponentType;
import wayoftime.bloodmagic.api.IBloodMagicAPI;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.incense.EnumTranquilityType;
import wayoftime.bloodmagic.incense.TranquilityStack;
public class BloodMagicCorePlugin
{
public static final BloodMagicCorePlugin INSTANCE = new BloodMagicCorePlugin();
public void register(IBloodMagicAPI apiInterface)
{
BloodMagicAPI api = (BloodMagicAPI) apiInterface;
api.getValueManager().setTranquility(Blocks.LAVA, new TranquilityStack(EnumTranquilityType.LAVA, 1.2D));
// api.getValueManager().setTranquility(Blocks.FLOWING_LAVA, new TranquilityStack(EnumTranquilityType.LAVA, 1.2D));
api.getValueManager().setTranquility(Blocks.WATER, new TranquilityStack(EnumTranquilityType.WATER, 1.0D));
// api.getValueManager().setTranquility(Blocks.water, new TranquilityStack(EnumTranquilityType.WATER, 1.0D));
api.getValueManager().setTranquility(BloodMagicBlocks.LIFE_ESSENCE_BLOCK.get(), new TranquilityStack(EnumTranquilityType.WATER, 1.5D));
api.getValueManager().setTranquility(Blocks.NETHERRACK, new TranquilityStack(EnumTranquilityType.FIRE, 0.5D));
api.getValueManager().setTranquility(Blocks.DIRT, new TranquilityStack(EnumTranquilityType.EARTHEN, 0.25D));
api.getValueManager().setTranquility(Blocks.FARMLAND, new TranquilityStack(EnumTranquilityType.EARTHEN, 1.0D));
api.getValueManager().setTranquility(Blocks.POTATOES, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
api.getValueManager().setTranquility(Blocks.CARROTS, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
api.getValueManager().setTranquility(Blocks.WHEAT, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
api.getValueManager().setTranquility(Blocks.NETHER_WART, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
api.getValueManager().setTranquility(Blocks.BEETROOTS, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
apiInterface.registerAltarComponent(Blocks.GLOWSTONE.getDefaultState(), ComponentType.GLOWSTONE.name());
apiInterface.registerAltarComponent(Blocks.SEA_LANTERN.getDefaultState(), ComponentType.GLOWSTONE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.BLOODSTONE.get().getDefaultState(), ComponentType.BLOODSTONE.name());
apiInterface.registerAltarComponent(Blocks.BEACON.getDefaultState(), ComponentType.BEACON.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.BLANK_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.SPEED_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.SACRIFICE_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.SELF_SACRIFICE_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.DISPLACEMENT_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.CAPACITY_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.AUGMENTED_CAPACITY_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.ORB_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.ACCELERATION_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
apiInterface.registerAltarComponent(BloodMagicBlocks.CHARGING_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
}
}

View file

@ -1,534 +0,0 @@
package wayoftime.bloodmagic.api.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import wayoftime.bloodmagic.api.IBloodMagicRecipeRegistrar;
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
import wayoftime.bloodmagic.common.recipe.BloodMagicRecipeType;
public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
{
// private final Set<RecipeBloodAltar> altarRecipes;
// private final Set<RecipeAlchemyTable> alchemyRecipes;
// private final Set<RecipeTartaricForge> tartaricForgeRecipes;
// private final Set<RecipeAlchemyArray> alchemyArrayRecipes;
// private final Set<RecipeSacrificeCraft> sacrificeCraftRecipes;
public BloodMagicRecipeRegistrar()
{
// this.altarRecipes = Sets.newHashSet();
// this.alchemyRecipes = Sets.newHashSet();
// this.tartaricForgeRecipes = Sets.newHashSet();
// this.alchemyArrayRecipes = Sets.newHashSet();
// this.sacrificeCraftRecipes = Sets.newHashSet();
}
// @Override
// public void addBloodAltar(@Nonnull Ingredient input, @Nonnull ItemStack output, @Nonnegative int minimumTier,
// @Nonnegative int syphon, @Nonnegative int consumeRate, @Nonnegative int drainRate)
// {
// Preconditions.checkNotNull(input, "input cannot be null.");
// Preconditions.checkNotNull(output, "output cannot be null.");
// Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
// Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
// Preconditions.checkArgument(consumeRate >= 0, "consumeRate cannot be negative.");
// Preconditions.checkArgument(drainRate >= 0, "drainRate cannot be negative.");
//
// // TODO: Got to adda ResourceLocation argument.
// altarRecipes.add(new IRecipeBloodAltar(null, input, output, minimumTier, syphon, consumeRate, drainRate));
// }
//
// @Override
// public boolean removeBloodAltar(@Nonnull ItemStack input)
// {
// Preconditions.checkNotNull(input, "input cannot be null.");
//
// return altarRecipes.remove(getBloodAltar(input));
// }
// @Override
// public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks,
// @Nonnegative int minimumTier, @Nonnull Ingredient... input)
// {
// Preconditions.checkNotNull(output, "output cannot be null.");
// Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
// Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
// Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
// Preconditions.checkNotNull(input, "input cannot be null.");
//
// NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
// alchemyRecipes.add(new RecipeAlchemyTable(inputs, output, syphon, ticks, minimumTier));
// }
//
// public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks,
// @Nonnegative int minimumTier, @Nonnull Object... input)
// {
// Preconditions.checkNotNull(output, "output cannot be null.");
// Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
// Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
// Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
// Preconditions.checkNotNull(input, "input cannot be null.");
//
// List<Ingredient> ingredients = Lists.newArrayList();
// for (Object object : input)
// {
// if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb)
// {
// ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
// continue;
// }
//
// ingredients.add(CraftingHelper.getIngredient(object));
// }
//
// addAlchemyTable(output, syphon, ticks, minimumTier, ingredients.toArray(new Ingredient[0]));
// }
//
// public void addAlchemyTable(RecipeAlchemyTable recipe)
// {
// alchemyRecipes.add(recipe);
// }
//
// @Override
// public boolean removeAlchemyTable(@Nonnull ItemStack... input)
// {
// Preconditions.checkNotNull(input, "inputs cannot be null.");
//
// for (ItemStack stack : input) Preconditions.checkNotNull(stack, "input cannot be null.");
//
// return alchemyRecipes.remove(getAlchemyTable(Lists.newArrayList(input)));
// }
//
// @Override
// public void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls,
// @Nonnegative double soulDrain, @Nonnull Ingredient... input)
// {
// Preconditions.checkNotNull(output, "output cannot be null.");
// Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
// Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
// Preconditions.checkNotNull(input, "input cannot be null.");
//
// NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
// tartaricForgeRecipes.add(new RecipeTartaricForge(inputs, output, minimumSouls, soulDrain));
// }
//
// @Override
// public boolean removeTartaricForge(@Nonnull ItemStack... input)
// {
// Preconditions.checkNotNull(input, "inputs cannot be null.");
//
// for (ItemStack stack : input) Preconditions.checkNotNull(stack, "input cannot be null.");
//
// return tartaricForgeRecipes.remove(getTartaricForge(Lists.newArrayList(input)));
// }
//
// public void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls,
// @Nonnegative double soulDrain, @Nonnull Object... input)
// {
// Preconditions.checkNotNull(output, "output cannot be null.");
// Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
// Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
// Preconditions.checkNotNull(input, "input cannot be null.");
//
// List<Ingredient> ingredients = Lists.newArrayList();
// for (Object object : input)
// {
// if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb)
// {
// ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
// continue;
// }
//
// ingredients.add(CraftingHelper.getIngredient(object));
// }
//
// addTartaricForge(output, minimumSouls, soulDrain, ingredients.toArray(new Ingredient[0]));
// }
//
// @Override
// public void addAlchemyArray(@Nonnull Ingredient input, @Nonnull Ingredient catalyst, @Nonnull ItemStack output,
// @Nullable ResourceLocation circleTexture)
// {
// Preconditions.checkNotNull(input, "input cannot be null.");
// Preconditions.checkNotNull(catalyst, "catalyst cannot be null.");
// Preconditions.checkNotNull(output, "output cannot be null.");
//
// alchemyArrayRecipes.add(new RecipeAlchemyArray(input, catalyst, output, circleTexture));
// }
//
// @Override
// public boolean removeAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst)
// {
// Preconditions.checkNotNull(input, "input cannot be null.");
// Preconditions.checkNotNull(catalyst, "catalyst cannot be null.");
//
// return alchemyArrayRecipes.remove(getAlchemyArray(input, catalyst));
// }
//
// public void addAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output,
// @Nullable ResourceLocation circleTexture)
// {
// Preconditions.checkNotNull(input, "input cannot be null.");
// Preconditions.checkNotNull(catalyst, "catalyst cannot be null.");
// Preconditions.checkNotNull(output, "output cannot be null.");
//
// addAlchemyArray(Ingredient.fromStacks(input), Ingredient.fromStacks(catalyst), output, circleTexture);
// }
//
// public void addSacrificeCraft(@Nonnull ItemStack output, @Nonnegative double healthRequired,
// @Nonnull Object... input)
// {
// Preconditions.checkNotNull(output, "output cannot be null.");
// Preconditions.checkArgument(healthRequired >= 0, "healthRequired cannot be negative.");
// Preconditions.checkNotNull(input, "input cannot be null.");
//
// List<Ingredient> ingredients = Lists.newArrayList();
// for (Object object : input)
// {
// if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb)
// {
// ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
// continue;
// }
//
// ingredients.add(CraftingHelper.getIngredient(object));
// }
//
// addSacrificeCraft(output, healthRequired, ingredients.toArray(new Ingredient[0]));
// }
//
// @Override
// public boolean removeSacrificeCraft(@Nonnull ItemStack... input)
// {
// Preconditions.checkNotNull(input, "inputs cannot be null.");
//
// for (ItemStack stack : input) Preconditions.checkNotNull(stack, "input cannot be null.");
//
// return sacrificeCraftRecipes.remove(getSacrificeCraft(Lists.newArrayList(input)));
// }
//
// @Override
// public void addSacrificeCraft(@Nonnull ItemStack output, @Nonnegative double healthRequired,
// @Nonnull Ingredient... input)
// {
// Preconditions.checkNotNull(output, "output cannot be null.");
// Preconditions.checkArgument(healthRequired >= 0, "healthRequired cannot be negative.");
// Preconditions.checkNotNull(input, "input cannot be null.");
//
// NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
// sacrificeCraftRecipes.add(new RecipeSacrificeCraft(inputs, output, healthRequired));
// }
@Nullable
public RecipeBloodAltar getBloodAltar(World world, @Nonnull ItemStack input)
{
Preconditions.checkNotNull(input, "input cannot be null.");
if (input.isEmpty())
return null;
List<RecipeBloodAltar> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR);
for (RecipeBloodAltar recipe : altarRecipes) if (recipe.getInput().test(input))
return recipe;
return null;
}
public RecipeARC getARC(World world, @Nonnull ItemStack input, @Nonnull ItemStack arcToolInput, @Nonnull FluidStack inputFluid)
{
Preconditions.checkNotNull(input, "input cannot be null.");
Preconditions.checkNotNull(arcToolInput, "tool cannot be null.");
if (input.isEmpty() || arcToolInput.isEmpty())
return null;
List<RecipeARC> arcRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARC);
for (RecipeARC recipe : arcRecipes)
{
if (recipe.getInput().test(input) && recipe.getTool().test(arcToolInput))
{
if (recipe.getFluidIngredient() == null)
{
return recipe;
} else if (recipe.getFluidIngredient().test(inputFluid))
{
return recipe;
}
}
}
// if (input.isEmpty())
// return null;
//
// List<RecipeBloodAltar> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR);
//
// for (RecipeBloodAltar recipe : altarRecipes) if (recipe.getInput().test(input))
// return recipe;
return null;
}
// @Nullable
// public RecipeAlchemyTable getAlchemyTable(@Nonnull List<ItemStack> input)
// {
// Preconditions.checkNotNull(input, "input cannot be null.");
// if (input.isEmpty())
// return null;
//
// mainLoop: for (RecipeAlchemyTable recipe : alchemyRecipes)
// {
// if (recipe.getInput().size() != input.size())
// continue;
//
// List<Ingredient> recipeInput = new ArrayList<>(recipe.getInput());
//
// for (int i = 0; i < input.size(); i++)
// {
// boolean matched = false;
// for (int j = 0; j < recipeInput.size(); j++)
// {
// Ingredient ingredient = recipeInput.get(j);
// if (ingredient.apply(input.get(i)))
// {
// matched = true;
// recipeInput.remove(j);
// break;
// }
// }
//
// if (!matched)
// continue mainLoop;
// }
//
// return recipe;
// }
//
// return null;
// }
//
@Nullable
public RecipeAlchemyTable getAlchemyTable(World world, @Nonnull List<ItemStack> input)
{
Preconditions.checkNotNull(input, "input cannot be null.");
if (input.isEmpty())
return null;
List<RecipeAlchemyTable> tartaricForgeRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALCHEMYTABLE);
mainLoop: for (RecipeAlchemyTable recipe : tartaricForgeRecipes)
{
if (recipe.getInput().size() != input.size())
continue;
List<Ingredient> recipeInput = new ArrayList<>(recipe.getInput());
for (int i = 0; i < input.size(); i++)
{
boolean matched = false;
for (int j = 0; j < recipeInput.size(); j++)
{
Ingredient ingredient = recipeInput.get(j);
if (ingredient.test(input.get(i)))
{
matched = true;
recipeInput.remove(j);
break;
}
}
if (!matched)
continue mainLoop;
}
return recipe;
}
return null;
}
@Nullable
public RecipeTartaricForge getTartaricForge(World world, @Nonnull List<ItemStack> input)
{
Preconditions.checkNotNull(input, "input cannot be null.");
if (input.isEmpty())
return null;
List<RecipeTartaricForge> tartaricForgeRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.TARTARICFORGE);
mainLoop: for (RecipeTartaricForge recipe : tartaricForgeRecipes)
{
if (recipe.getInput().size() != input.size())
continue;
List<Ingredient> recipeInput = new ArrayList<>(recipe.getInput());
for (int i = 0; i < input.size(); i++)
{
boolean matched = false;
for (int j = 0; j < recipeInput.size(); j++)
{
Ingredient ingredient = recipeInput.get(j);
if (ingredient.test(input.get(i)))
{
matched = true;
recipeInput.remove(j);
break;
}
}
if (!matched)
continue mainLoop;
}
return recipe;
}
return null;
}
//
// @Nullable
// public RecipeSacrificeCraft getSacrificeCraft(@Nonnull List<ItemStack> input)
// {
// Preconditions.checkNotNull(input, "input cannot be null.");
// if (input.isEmpty())
// return null;
//
// mainLoop: for (RecipeSacrificeCraft recipe : sacrificeCraftRecipes)
// {
// if (recipe.getInput().size() != input.size())
// continue;
//
// List<Ingredient> recipeInput = new ArrayList<>(recipe.getInput());
//
// for (int i = 0; i < input.size(); i++)
// {
// boolean matched = false;
// for (int j = 0; j < recipeInput.size(); j++)
// {
// Ingredient ingredient = recipeInput.get(j);
// if (ingredient.apply(input.get(i)))
// {
// matched = true;
// recipeInput.remove(j);
// break;
// }
// }
//
// if (!matched)
// continue mainLoop;
// }
//
// return recipe;
// }
//
// return null;
// }
//
/**
*
* @param world
* @param input
* @param catalyst
* @return If false and the recipe is nonnull, it is a partial match. If true,
* the returned recipe is a full match.
*/
@Nullable
public Pair<Boolean, RecipeAlchemyArray> getAlchemyArray(World world, @Nonnull ItemStack input, @Nonnull ItemStack catalyst)
{
Preconditions.checkNotNull(input, "input cannot be null.");
if (input.isEmpty())
return null;
List<RecipeAlchemyArray> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY);
RecipeAlchemyArray partialMatch = null;
for (RecipeAlchemyArray recipe : altarRecipes)
{
if (recipe.getBaseInput().test(input))
{
if (recipe.getAddedInput().test(catalyst))
{
return Pair.of(true, recipe);
} else if (partialMatch == null)
{
partialMatch = recipe;
}
}
}
return Pair.of(false, partialMatch);
}
public Set<RecipeBloodAltar> getAltarRecipes(World world)
{
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR));
}
public Set<RecipeTartaricForge> getTartaricForgeRecipes(World world)
{
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.TARTARICFORGE));
}
public Set<RecipeAlchemyArray> getAlchemyArrayRecipes(World world)
{
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY));
}
public Set<RecipeARC> getARCRecipes(World world)
{
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARC));
}
public Set<RecipeAlchemyTable> getAlchemyTableRecipes(World world)
{
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALCHEMYTABLE));
}
public Set<RecipeAlchemyArray> getCraftingAlchemyArrayRecipes(World world)
{
Set<RecipeAlchemyArray> recipes = Set.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY));
Set<RecipeAlchemyArray> copyRecipes = Set.of();
for (RecipeAlchemyArray recipe : recipes)
{
if (!recipe.getOutput().isEmpty())
{
copyRecipes.add(recipe);
}
}
return copyRecipes;
}
// public Set<RecipeAlchemyTable> getAlchemyRecipes()
// {
// return ImmutableSet.copyOf(alchemyRecipes);
// }
//
// public Set<RecipeTartaricForge> getTartaricForgeRecipes()
// {
// return ImmutableSet.copyOf(tartaricForgeRecipes);
// }
//
// public Set<RecipeAlchemyArray> getAlchemyArrayRecipes()
// {
// return ImmutableSet.copyOf(alchemyArrayRecipes);
// }
}

View file

@ -1,76 +0,0 @@
package wayoftime.bloodmagic.api.impl;
import java.util.Map;
import javax.annotation.Nonnull;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.ResourceLocation;
import wayoftime.bloodmagic.api.IBloodMagicValueManager;
import wayoftime.bloodmagic.incense.EnumTranquilityType;
import wayoftime.bloodmagic.incense.TranquilityStack;
import wayoftime.bloodmagic.util.BMLog;
public class BloodMagicValueManager implements IBloodMagicValueManager
{
private final Map<ResourceLocation, Integer> sacrificial;
private final Map<BlockState, TranquilityStack> tranquility;
public BloodMagicValueManager()
{
this.sacrificial = Maps.newHashMap();
this.tranquility = Maps.newHashMap();
}
@Override
public void setSacrificialValue(@Nonnull ResourceLocation entityId, int value)
{
BMLog.API_VERBOSE.info("Value Manager: Set sacrificial value of {} to {}.", entityId, value);
sacrificial.put(entityId, value);
}
@Override
public void setTranquility(@Nonnull BlockState state, @Nonnull String tranquilityType, double value)
{
EnumTranquilityType tranquility = null;
for (EnumTranquilityType type : EnumTranquilityType.values())
{
if (type.name().equalsIgnoreCase(tranquilityType))
{
tranquility = type;
break;
}
}
if (tranquility != null)
{
BMLog.API_VERBOSE.info("Value Manager: Set tranquility value of {} to {} @ {}", state, tranquilityType, value);
this.tranquility.put(state, new TranquilityStack(tranquility, value));
} else
BMLog.API.warn("Invalid tranquility type: {}.", tranquilityType);
}
public void setTranquility(Block block, TranquilityStack tranquilityStack)
{
for (BlockState state : block.getStateContainer().getValidStates())
{
BMLog.API_VERBOSE.info("Value Manager: Set tranquility value of {} to {} @ {}", state, tranquilityStack.type, tranquilityStack.value);
tranquility.put(state, tranquilityStack);
}
}
public Map<ResourceLocation, Integer> getSacrificial()
{
return ImmutableMap.copyOf(sacrificial);
}
public Map<BlockState, TranquilityStack> getTranquility()
{
return ImmutableMap.copyOf(tranquility);
}
}

View file

@ -0,0 +1,16 @@
package wayoftime.bloodmagic.api.item;
import net.minecraft.item.ItemStack;
public interface IARCTool
{
default double getCraftingSpeedMultiplier(ItemStack stack)
{
return 1;
}
default double getAdditionalOutputChanceMultiplier(ItemStack stack)
{
return 1;
}
}

View file

@ -0,0 +1,32 @@
package wayoftime.bloodmagic.api.item;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import wayoftime.bloodmagic.util.Constants;
/**
* Interface for activatable items
*/
public interface IActivatable
{
default boolean getActivated(ItemStack stack)
{
return !stack.isEmpty() && stack.hasTag() && stack.getTag().getBoolean(Constants.NBT.ACTIVATED);
}
@Nonnull
default ItemStack setActivatedState(ItemStack stack, boolean activated)
{
if (!stack.isEmpty())
{
if (!stack.hasTag())
stack.setTag(new CompoundNBT());
stack.getTag().putBoolean(Constants.NBT.ACTIVATED, activated);
}
return stack;
}
}

View file

@ -0,0 +1,10 @@
package wayoftime.bloodmagic.api.item;
/**
* Any item that implements this interface will not be pulled into the Altar on
* right click.
*/
public interface IAltarReader
{
}

View file

@ -0,0 +1,40 @@
package wayoftime.bloodmagic.api.item;
import javax.annotation.Nullable;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import wayoftime.bloodmagic.core.data.Binding;
/**
* Implement this interface on any Item that can be bound to a player.
*/
public interface IBindable
{
/**
* Gets an object that stores who this item is bound to.
* <p>
* If the item is not bound, this will be null.
*
* @param stack - The owned ItemStack
* @return - The binding object
*/
@Nullable
default Binding getBinding(ItemStack stack)
{
Binding binding = Binding.fromStack(stack);
return !stack.isEmpty() && binding != null ? binding : null;
}
/**
* Called when the player attempts to bind the item.
*
* @param player - The Player attempting to bind the item
* @param stack - The ItemStack to attempt binding
* @return If binding was successful.
*/
default boolean onBind(PlayerEntity player, ItemStack stack)
{
return true;
}
}

View file

@ -0,0 +1,12 @@
package wayoftime.bloodmagic.api.item;
import net.minecraft.item.ItemStack;
/**
* An interface for items that have custom drainage behaviour when used in
* certain alchemy recipes.
*/
public interface ICustomAlchemyConsumable
{
ItemStack drainUseOnAlchemyCraft(ItemStack stack);
}

View file

@ -0,0 +1,12 @@
package wayoftime.bloodmagic.api.item;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IDemonWillViewer
{
boolean canSeeDemonWillAura(World world, ItemStack stack, PlayerEntity player);
int getDemonWillAuraResolution(World world, ItemStack stack, PlayerEntity player);
}

View file

@ -0,0 +1,9 @@
package wayoftime.bloodmagic.api.item;
import net.minecraft.item.ItemStack;
import wayoftime.bloodmagic.will.EnumDemonWillType;
public interface IMultiWillTool
{
EnumDemonWillType getCurrentType(ItemStack stack);
}

View file

@ -0,0 +1,32 @@
package wayoftime.bloodmagic.api.item;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import wayoftime.bloodmagic.common.item.ItemSigil;
/**
* Used for all {@link ItemSigil} <b>EXCEPT</b> Sigils of Holdings.
*/
public interface ISigil
{
default boolean performArrayEffect(World world, BlockPos pos)
{
return false;
}
default boolean hasArrayEffect()
{
return false;
}
interface Holding
{
@Nonnull
ItemStack getHeldItem(ItemStack holdingStack, PlayerEntity player);
}
}

View file

@ -1,4 +1,4 @@
package wayoftime.bloodmagic.api.impl.recipe;
package wayoftime.bloodmagic.api.recipe;
import javax.annotation.Nonnull;

View file

@ -1,4 +1,4 @@
package wayoftime.bloodmagic.api.impl.recipe;
package wayoftime.bloodmagic.api.recipe;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,4 +1,4 @@
package wayoftime.bloodmagic.api.impl.recipe;
package wayoftime.bloodmagic.api.recipe;
import javax.annotation.Nonnull;

View file

@ -1,4 +1,4 @@
package wayoftime.bloodmagic.api.impl.recipe;
package wayoftime.bloodmagic.api.recipe;
import java.util.List;

View file

@ -1,4 +1,4 @@
package wayoftime.bloodmagic.api.impl.recipe;
package wayoftime.bloodmagic.api.recipe;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;

View file

@ -1,4 +1,4 @@
package wayoftime.bloodmagic.api.impl.recipe;
package wayoftime.bloodmagic.api.recipe;
import java.util.List;

View file

@ -0,0 +1,14 @@
package wayoftime.bloodmagic.api.tile;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import wayoftime.bloodmagic.altar.ComponentType;
public interface IAltarComponent
{
@Nullable
ComponentType getType(World world, BlockState state, BlockPos pos);
}

View file

@ -0,0 +1,57 @@
package wayoftime.bloodmagic.api.tile;
import wayoftime.bloodmagic.altar.AltarTier;
public interface IBloodAltar
{
int getCapacity();
int getCurrentBlood();
AltarTier getTier();
int getProgress();
float getSacrificeMultiplier();
float getSelfSacrificeMultiplier();
float getOrbMultiplier();
float getDislocationMultiplier();
float getConsumptionMultiplier();
float getConsumptionRate();
int getChargingRate();
int getChargingFrequency();
int getTotalCharge();
int getLiquidRequired();
int getBufferCapacity();
void sacrificialDaggerCall(int amount, boolean isSacrifice);
void startCycle();
void checkTier();
boolean isActive();
void setActive();
int fillMainTank(int amount);
/**
* Will set the altar to initiate a cooldown cycle after it crafts before
* starting to craft again, giving the user time to interact with the altar.
* This can only be set while the altar is not active.
*
* @param cooldown - How long the cooldown should last
*/
void requestPauseAfterCrafting(int cooldown);
}

View file

@ -0,0 +1,16 @@
package wayoftime.bloodmagic.api.tile;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
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
*/
public interface IBloodRune
{
@Nullable
BloodRuneType getBloodRune(World world, BlockPos pos);
}