Implemented the Mob Sacrifice Array.
Needs some cleaning up + added visuals, but appears functional.
This commit is contained in:
parent
32227afd9d
commit
389043dc64
10 changed files with 644 additions and 35 deletions
|
@ -25,10 +25,12 @@ import net.minecraftforge.fml.common.registry.EntityEntry;
|
|||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
@BloodMagicPlugin
|
||||
public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
||||
public class BloodMagicCorePlugin implements IBloodMagicPlugin
|
||||
{
|
||||
|
||||
@Override
|
||||
public void register(IBloodMagicAPI apiInterface) {
|
||||
public void register(IBloodMagicAPI apiInterface)
|
||||
{
|
||||
BloodMagicAPI api = (BloodMagicAPI) apiInterface;
|
||||
// Add forced blacklistings
|
||||
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.INPUT_ROUTING_NODE);
|
||||
|
@ -82,15 +84,19 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes(IBloodMagicRecipeRegistrar recipeRegistrar) {
|
||||
public void registerRecipes(IBloodMagicRecipeRegistrar recipeRegistrar)
|
||||
{
|
||||
RegistrarBloodMagicRecipes.registerAltarRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerAlchemyTableRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerTartaricForgeRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerAlchemyArrayRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerSacrificeCraftRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
}
|
||||
|
||||
private static void handleConfigValues(BloodMagicAPI api) {
|
||||
for (String value : ConfigHandler.values.sacrificialValues) {
|
||||
private static void handleConfigValues(BloodMagicAPI api)
|
||||
{
|
||||
for (String value : ConfigHandler.values.sacrificialValues)
|
||||
{
|
||||
String[] split = value.split(";");
|
||||
if (split.length != 2) // Not valid format
|
||||
continue;
|
||||
|
@ -98,15 +104,18 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
|||
api.getValueManager().setSacrificialValue(new ResourceLocation(split[0]), Integer.parseInt(split[1]));
|
||||
}
|
||||
|
||||
for (String value : ConfigHandler.blacklist.teleposer) {
|
||||
for (String value : ConfigHandler.blacklist.teleposer)
|
||||
{
|
||||
EntityEntry entityEntry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(value));
|
||||
if (entityEntry == null) { // It's not an entity (or at least not a valid one), so let's try a block.
|
||||
if (entityEntry == null)
|
||||
{ // It's not an entity (or at least not a valid one), so let's try a block.
|
||||
String[] blockData = value.split("\\[");
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0]));
|
||||
if (block == Blocks.AIR || block == null) // Not a valid block either
|
||||
continue;
|
||||
|
||||
if (blockData.length > 1) { // We have properties listed, so let's build a state.
|
||||
if (blockData.length > 1)
|
||||
{ // We have properties listed, so let's build a state.
|
||||
api.getBlacklist().addTeleposer(parseState(value));
|
||||
continue;
|
||||
}
|
||||
|
@ -118,13 +127,15 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
|||
api.getBlacklist().addTeleposer(entityEntry.getRegistryName());
|
||||
}
|
||||
|
||||
for (String value : ConfigHandler.blacklist.transposer) {
|
||||
for (String value : ConfigHandler.blacklist.transposer)
|
||||
{
|
||||
String[] blockData = value.split("\\[");
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0]));
|
||||
if (block == Blocks.AIR || block == null) // Not a valid block
|
||||
continue;
|
||||
|
||||
if (blockData.length > 1) { // We have properties listed, so let's build a state.
|
||||
if (blockData.length > 1)
|
||||
{ // We have properties listed, so let's build a state.
|
||||
api.getBlacklist().addTeleposer(parseState(value));
|
||||
continue;
|
||||
}
|
||||
|
@ -132,7 +143,8 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
|||
api.getBlacklist().addTeleposer(block);
|
||||
}
|
||||
|
||||
for (String value : ConfigHandler.blacklist.wellOfSuffering) {
|
||||
for (String value : ConfigHandler.blacklist.wellOfSuffering)
|
||||
{
|
||||
EntityEntry entityEntry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(value));
|
||||
if (entityEntry == null) // Not a valid entity
|
||||
continue;
|
||||
|
@ -141,7 +153,8 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
private static IBlockState parseState(String blockInfo) {
|
||||
private static IBlockState parseState(String blockInfo)
|
||||
{
|
||||
String[] split = blockInfo.split("\\[");
|
||||
split[1] = split[1].substring(0, split[1].lastIndexOf("]")); // Make sure brackets are removed from state
|
||||
|
||||
|
@ -154,7 +167,8 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
|||
|
||||
// Force our values into the state
|
||||
String[] stateValues = split[1].split(","); // Splits up each value
|
||||
for (String value : stateValues) {
|
||||
for (String value : stateValues)
|
||||
{
|
||||
String[] valueSplit = value.split("="); // Separates property and value
|
||||
IProperty property = blockState.getProperty(valueSplit[0]);
|
||||
if (property != null)
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
package WayofTime.bloodmagic.api.impl;
|
||||
|
||||
import WayofTime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
||||
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.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.core.recipe.IngredientBloodOrb;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import WayofTime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
||||
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.RecipeSacrificeCraft;
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
|
||||
import WayofTime.bloodmagic.core.recipe.IngredientBloodOrb;
|
||||
import WayofTime.bloodmagic.orb.IBloodOrb;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
|
|||
private final Set<RecipeAlchemyTable> alchemyRecipes;
|
||||
private final Set<RecipeTartaricForge> tartaricForgeRecipes;
|
||||
private final Set<RecipeAlchemyArray> alchemyArrayRecipes;
|
||||
private final Set<RecipeSacrificeCraft> sacrificeCraftRecipes;
|
||||
|
||||
public BloodMagicRecipeRegistrar()
|
||||
{
|
||||
|
@ -41,6 +42,7 @@ public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
|
|||
this.alchemyRecipes = Sets.newHashSet();
|
||||
this.tartaricForgeRecipes = Sets.newHashSet();
|
||||
this.alchemyArrayRecipes = Sets.newHashSet();
|
||||
this.sacrificeCraftRecipes = Sets.newHashSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -189,6 +191,49 @@ public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
|
|||
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(@Nonnull ItemStack input)
|
||||
{
|
||||
|
@ -279,6 +324,44 @@ public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
|
|||
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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RecipeAlchemyArray getAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package WayofTime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RecipeSacrificeCraft
|
||||
{
|
||||
@Nonnull
|
||||
private final NonNullList<Ingredient> input;
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
@Nonnegative
|
||||
private final double healthRequired;
|
||||
|
||||
public RecipeSacrificeCraft(@Nonnull NonNullList<Ingredient> input, @Nonnull ItemStack output, @Nonnegative double healthRequired)
|
||||
{
|
||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
||||
Preconditions.checkNotNull(output, "output cannot be null.");
|
||||
Preconditions.checkArgument(healthRequired >= 0, "healthRequired cannot be negative.");
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.healthRequired = healthRequired;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final NonNullList<Ingredient> getInput()
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final ItemStack getOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
@Nonnegative
|
||||
public final double getHealthRequired()
|
||||
{
|
||||
return healthRequired;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue