Attempt to try to fix the 1.16.3's branch having multiple 'wayoftime' folders.

This commit is contained in:
WayofTime 2020-10-29 15:48:44 -04:00
parent c159828248
commit 6b4145a67c
224 changed files with 0 additions and 24047 deletions

View file

@ -1,80 +0,0 @@
package wayoftime.bloodmagic.api;
import javax.annotation.Nonnull;
import net.minecraft.block.BlockState;
/**
* The main interface between a plugin and Blood Magic's internals.
*
* This API is intended for <i>compatibility</i> between other mods and Blood
* 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}.
*/
public interface IBloodMagicAPI
{
// /**
// * Retrieves the instance of the blacklist.
// *
// * @return the active {@link IBloodMagicBlacklist} instance
// */
// @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();
/**
* Registers an {@link IBlockState} as a given component for the Blood Altar.
* <p>
* Valid component types:
* <ul>
* <li>GLOWSTONE</li>
* <li>BLOODSTONE</li>
* <li>BEACON</li>
* <li>BLOODRUNE</li>
* <li>CRYSTAL</li>
* <li>NOTAIR</li>
* </ul>
*
* @param state The state to register
* @param componentType The type of Blood Altar component to register as.
*/
void registerAltarComponent(@Nonnull BlockState state, @Nonnull String componentType);
/**
* Removes an {@link IBlockState} from the component mappings
* <p>
* Valid component types:
* <ul>
* <li>GLOWSTONE</li>
* <li>BLOODSTONE</li>
* <li>BEACON</li>
* <li>BLOODRUNE</li>
* <li>CRYSTAL</li>
* <li>NOTAIR</li>
* </ul>
*
* @param state The state to unregister
* @param componentType The type of Blood Altar component to unregister from.
*/
void unregisterAltarComponent(@Nonnull BlockState state, @Nonnull String componentType);
}

View file

@ -1,100 +0,0 @@
package wayoftime.bloodmagic.api;
/**
* Allows recipe addition and removal.
*/
public interface IBloodMagicRecipeRegistrar
{
// /**
// * Adds a new recipe to the Blood Altar.
// *
// * @param input An input {@link Ingredient}.
// * @param output An output {@link ItemStack}.
// * @param minimumTier The minimum Blood Altar tier required for this recipe.
// * @param syphon The amount of Life Essence to syphon from the Blood Altar
// * over the course of the craft.
// * @param consumeRate How quickly the Life Essence is syphoned.
// * @param drainRate How quickly progress is lost if the Blood Altar runs out
// * of Life Essence during the craft.
// */
// void addBloodAltar(@Nonnull Ingredient input, @Nonnull ItemStack output, @Nonnegative int minimumTier,
// @Nonnegative int syphon, @Nonnegative int consumeRate, @Nonnegative int drainRate);
//
// /**
// * Removes a Blood Altar recipe based on an input {@link ItemStack}.
// *
// * @param input The input item to remove the recipe of.
// * @return Whether or not a recipe was removed.
// */
// boolean removeBloodAltar(@Nonnull ItemStack input);
//
// /**
// * Adds a new recipe to the Alchemy Table.
// *
// * @param output An output {@link ItemStack}.
// * @param syphon The amount of Life Essence to syphon from the Blood Orb's
// * bound network over the course of the craft.
// * @param ticks The amount of ticks it takes to complete the craft.
// * @param minimumTier The minimum Blood Orb tier required for this recipe.
// * @param input An array of {@link Ingredient}s to accept as inputs.
// */
// void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks,
// @Nonnegative int minimumTier, @Nonnull Ingredient... input);
//
// /**
// * Removes an Alchemy Table recipe based on an input {@link ItemStack} array.
// *
// * @param input The input items to remove the recipe of.
// * @return Whether or not a recipe was removed.
// */
// boolean removeAlchemyTable(@Nonnull ItemStack... input);
//
// /**
// * Adds a new recipe to the Soul/Tartaric Forge.
// *
// * @param output An output {@link ItemStack}.
// * @param minimumSouls The minimum number of souls that must be contained in the
// * Soul Gem.
// * @param soulDrain The number of souls to drain from the Soul Gem.
// * @param input An array of {@link Ingredient}s to accept as inputs.
// */
// void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain,
// @Nonnull Ingredient... input);
//
// /**
// * Removes a Soul/Tartaric Forge recipe based on an input {@link ItemStack}
// * array.
// *
// * @param input The input items to remove the recipe of.
// * @return Whether or not a recipe was removed.
// */
// boolean removeTartaricForge(@Nonnull ItemStack... input);
//
// /**
// * Adds a new recipe to the Alchemy Array.
// *
// * @param input An input {@link Ingredient}. First item put into the
// * Alchemy Array.
// * @param catalyst A catalyst {@link Ingredient}. Second item put into the
// * Alchemy Array.
// * @param output An output {@link ItemStack}.
// * @param circleTexture The texture to render for the Alchemy Array circle.
// */
// void addAlchemyArray(@Nonnull Ingredient input, @Nonnull Ingredient catalyst, @Nonnull ItemStack output,
// @Nullable ResourceLocation circleTexture);
//
// /**
// * Removes an Alchemy Array recipe based on an input {@link ItemStack} and it's
// * catalyst {@link ItemStack}.
// *
// * @param input The input item to remove the recipe of.
// * @param catalyst The catalyst item to remove the recipe of.
// * @return Whether or not a recipe was removed.
// */
// boolean removeAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst);
//
// void addSacrificeCraft(@Nonnull ItemStack output, @Nonnegative double healthRequired, @Nonnull Ingredient... input);
//
// boolean removeSacrificeCraft(@Nonnull ItemStack... input);
}

View file

@ -1,129 +0,0 @@
package wayoftime.bloodmagic.api;
import javax.annotation.Nonnull;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapedRecipe;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
import wayoftime.bloodmagic.util.Constants;
/**
* Copied liberally from Mekanism. Thanks, pupnewfster!
*
*/
public class SerializerHelper
{
private SerializerHelper()
{
}
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
private static void validateKey(@Nonnull JsonObject json, @Nonnull String key)
{
if (!json.has(key))
{
throw new JsonSyntaxException("Missing '" + key + "', expected to find an object");
}
if (!json.get(key).isJsonObject())
{
throw new JsonSyntaxException("Expected '" + key + "' to be an object");
}
}
public static ItemStack getItemStack(@Nonnull JsonObject json, @Nonnull String key)
{
validateKey(json, key);
return ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, key));
}
public static JsonElement serializeItemStack(@Nonnull ItemStack stack)
{
JsonObject json = new JsonObject();
json.addProperty(Constants.JSON.ITEM, stack.getItem().getRegistryName().toString());
if (stack.getCount() > 1)
{
json.addProperty(Constants.JSON.COUNT, stack.getCount());
}
if (stack.hasTag())
{
json.addProperty(Constants.JSON.NBT, stack.getTag().toString());
}
return json;
}
public static FluidStack getFluidStack(@Nonnull JsonObject json, @Nonnull String key)
{
validateKey(json, key);
return deserializeFluid(JSONUtils.getJsonObject(json, key));
}
public static FluidStack deserializeFluid(@Nonnull JsonObject json)
{
if (!json.has(Constants.JSON.AMOUNT))
{
throw new JsonSyntaxException("Expected to receive a amount that is greater than zero");
}
JsonElement count = json.get(Constants.JSON.AMOUNT);
if (!JSONUtils.isNumber(count))
{
throw new JsonSyntaxException("Expected amount to be a number greater than zero.");
}
int amount = count.getAsJsonPrimitive().getAsInt();
if (amount < 1)
{
throw new JsonSyntaxException("Expected amount to be greater than zero.");
}
ResourceLocation resourceLocation = new ResourceLocation(JSONUtils.getString(json, Constants.JSON.FLUID));
Fluid fluid = ForgeRegistries.FLUIDS.getValue(resourceLocation);
if (fluid == null || fluid == Fluids.EMPTY)
{
throw new JsonSyntaxException("Invalid fluid type '" + resourceLocation + "'");
}
CompoundNBT nbt = null;
if (json.has(Constants.JSON.NBT))
{
JsonElement jsonNBT = json.get(Constants.JSON.NBT);
try
{
if (jsonNBT.isJsonObject())
{
nbt = JsonToNBT.getTagFromJson(GSON.toJson(jsonNBT));
} else
{
nbt = JsonToNBT.getTagFromJson(JSONUtils.getString(jsonNBT, Constants.JSON.NBT));
}
} catch (CommandSyntaxException e)
{
throw new JsonSyntaxException("Invalid NBT entry for fluid '" + resourceLocation + "'");
}
}
return new FluidStack(fluid, amount, nbt);
}
public static JsonElement serializeFluidStack(@Nonnull FluidStack stack)
{
JsonObject json = new JsonObject();
json.addProperty(Constants.JSON.FLUID, stack.getFluid().getRegistryName().toString());
json.addProperty(Constants.JSON.AMOUNT, stack.getAmount());
if (stack.hasTag())
{
json.addProperty(Constants.JSON.NBT, stack.getTag().toString());
}
return json;
}
}

View file

@ -1,84 +0,0 @@
package wayoftime.bloodmagic.api.event;
import net.minecraft.item.ItemStack;
import net.minecraftforge.eventbus.api.Event;
public class BloodMagicCraftedEvent extends Event
{
private final boolean modifiable;
private final ItemStack[] inputs;
private ItemStack output;
public BloodMagicCraftedEvent(ItemStack output, ItemStack[] inputs, boolean modifiable)
{
this.modifiable = modifiable;
this.inputs = inputs;
this.output = output;
}
public boolean isModifiable()
{
return modifiable;
}
public ItemStack[] getInputs()
{
return inputs;
}
public ItemStack getOutput()
{
return output;
}
public void setOutput(ItemStack output)
{
if (isModifiable())
this.output = output;
}
/**
* Fired whenever a craft is completed in a Blood Altar.
*
* It is not cancelable, however you can modify the output stack.
*/
public static class Altar extends BloodMagicCraftedEvent
{
public Altar(ItemStack output, ItemStack input)
{
super(output, new ItemStack[]
{ input }, true);
}
}
/**
* Fired whenever a craft is completed in a Soul Forge.
*
* It is not cancelable, however you can modify the output stack.
*/
public static class SoulForge extends BloodMagicCraftedEvent
{
public SoulForge(ItemStack output, ItemStack[] inputs)
{
super(output, inputs, true);
}
}
/**
* Fired whenever a craft is completed in an Alchemy Table.
*
* It is not cancelable, however you can modify the output stack.
*/
public static class AlchemyTable extends BloodMagicCraftedEvent
{
public AlchemyTable(ItemStack output, ItemStack[] inputs)
{
super(output, inputs, true);
}
}
}

View file

@ -1,385 +0,0 @@
package wayoftime.bloodmagic.api.event.recipes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import net.minecraft.fluid.Fluid;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ITag;
import net.minecraft.tags.TagCollectionManager;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import wayoftime.bloodmagic.api.SerializerHelper;
import wayoftime.bloodmagic.util.Constants;
/**
* Created by Thiakil on 12/07/2019.
*/
public abstract class FluidStackIngredient implements InputIngredient<FluidStack>
{
public static FluidStackIngredient from(@Nonnull Fluid instance, int amount)
{
return from(new FluidStack(instance, amount));
}
public static FluidStackIngredient from(@Nonnull FluidStack instance)
{
return new Single(instance);
}
public static FluidStackIngredient from(@Nonnull ITag<Fluid> fluidTag, int minAmount)
{
return new Tagged(fluidTag, minAmount);
}
public static FluidStackIngredient read(PacketBuffer buffer)
{
// TODO: Allow supporting serialization of different types than just the ones we
// implement?
IngredientType type = buffer.readEnumValue(IngredientType.class);
if (type == IngredientType.SINGLE)
{
return Single.read(buffer);
} else if (type == IngredientType.TAGGED)
{
return Tagged.read(buffer);
}
return Multi.read(buffer);
}
public static FluidStackIngredient deserialize(@Nullable JsonElement json)
{
if (json == null || json.isJsonNull())
{
throw new JsonSyntaxException("Ingredient cannot be null");
}
if (json.isJsonArray())
{
JsonArray jsonArray = json.getAsJsonArray();
int size = jsonArray.size();
if (size == 0)
{
throw new JsonSyntaxException("Ingredient array cannot be empty, at least one ingredient must be defined");
} else if (size > 1)
{
FluidStackIngredient[] ingredients = new FluidStackIngredient[size];
for (int i = 0; i < size; i++)
{
// Read all the ingredients
ingredients[i] = deserialize(jsonArray.get(i));
}
return createMulti(ingredients);
}
// If we only have a single element, just set our json as that so that we don't
// have to use Multi for efficiency reasons
json = jsonArray.get(0);
}
if (!json.isJsonObject())
{
throw new JsonSyntaxException("Expected fluid to be object or array of objects");
}
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.has(Constants.JSON.FLUID) && jsonObject.has(Constants.JSON.TAG))
{
throw new JsonParseException("An ingredient entry is either a tag or an fluid, not both");
} else if (jsonObject.has(Constants.JSON.FLUID))
{
return from(SerializerHelper.deserializeFluid(jsonObject));
} else if (jsonObject.has(Constants.JSON.TAG))
{
if (!jsonObject.has(Constants.JSON.AMOUNT))
{
throw new JsonSyntaxException("Expected to receive a amount that is greater than zero");
}
JsonElement count = jsonObject.get(Constants.JSON.AMOUNT);
if (!JSONUtils.isNumber(count))
{
throw new JsonSyntaxException("Expected amount to be a number greater than zero.");
}
int amount = count.getAsJsonPrimitive().getAsInt();
if (amount < 1)
{
throw new JsonSyntaxException("Expected amount to be greater than zero.");
}
ResourceLocation resourceLocation = new ResourceLocation(JSONUtils.getString(jsonObject, Constants.JSON.TAG));
ITag<Fluid> tag = TagCollectionManager.getManager().getFluidTags().get(resourceLocation);
if (tag == null)
{
throw new JsonSyntaxException("Unknown fluid tag '" + resourceLocation + "'");
}
return from(tag, amount);
}
throw new JsonSyntaxException("Expected to receive a resource location representing either a tag or a fluid.");
}
public static FluidStackIngredient createMulti(FluidStackIngredient... ingredients)
{
if (ingredients.length == 0)
{
// TODO: Throw error
} else if (ingredients.length == 1)
{
return ingredients[0];
}
List<FluidStackIngredient> cleanedIngredients = new ArrayList<>();
for (FluidStackIngredient ingredient : ingredients)
{
if (ingredient instanceof Multi)
{
// Don't worry about if our inner ingredients are multi as well, as if this is
// the only external method for
// creating a multi ingredient, then we are certified they won't be of a higher
// depth
cleanedIngredients.addAll(Arrays.asList(((Multi) ingredient).ingredients));
} else
{
cleanedIngredients.add(ingredient);
}
}
// There should be more than a single fluid or we would have split out earlier
return new Multi(cleanedIngredients.toArray(new FluidStackIngredient[0]));
}
public static class Single extends FluidStackIngredient
{
@Nonnull
private final FluidStack fluidInstance;
public Single(@Nonnull FluidStack fluidInstance)
{
this.fluidInstance = Objects.requireNonNull(fluidInstance);
}
@Override
public boolean test(@Nonnull FluidStack fluidStack)
{
return testType(fluidStack) && fluidStack.getAmount() >= fluidInstance.getAmount();
}
@Override
public boolean testType(@Nonnull FluidStack fluidStack)
{
return Objects.requireNonNull(fluidStack).isFluidEqual(fluidInstance);
}
@Nonnull
@Override
public FluidStack getMatchingInstance(@Nonnull FluidStack fluidStack)
{
return test(fluidStack) ? fluidInstance : FluidStack.EMPTY;
}
@Nonnull
@Override
public List<FluidStack> getRepresentations()
{
return Collections.singletonList(fluidInstance);
}
@Override
public void write(PacketBuffer buffer)
{
buffer.writeEnumValue(IngredientType.SINGLE);
fluidInstance.writeToPacket(buffer);
}
@Nonnull
@Override
public JsonElement serialize()
{
JsonObject json = new JsonObject();
json.addProperty(Constants.JSON.AMOUNT, fluidInstance.getAmount());
json.addProperty(Constants.JSON.FLUID, fluidInstance.getFluid().getRegistryName().toString());
if (fluidInstance.hasTag())
{
json.addProperty(Constants.JSON.NBT, fluidInstance.getTag().toString());
}
return json;
}
public static Single read(PacketBuffer buffer)
{
return new Single(FluidStack.readFromPacket(buffer));
}
}
public static class Tagged extends FluidStackIngredient
{
@Nonnull
private final ITag<Fluid> tag;
private final int amount;
public Tagged(@Nonnull ITag<Fluid> tag, int amount)
{
this.tag = tag;
this.amount = amount;
}
@Override
public boolean test(@Nonnull FluidStack fluidStack)
{
return testType(fluidStack) && fluidStack.getAmount() >= amount;
}
@Override
public boolean testType(@Nonnull FluidStack fluidStack)
{
return Objects.requireNonNull(fluidStack).getFluid().isIn(tag);
}
@Nonnull
@Override
public FluidStack getMatchingInstance(@Nonnull FluidStack fluidStack)
{
if (test(fluidStack))
{
// Our fluid is in the tag so we make a new stack with the given amount
return new FluidStack(fluidStack, amount);
}
return FluidStack.EMPTY;
}
@Nonnull
@Override
public List<FluidStack> getRepresentations()
{
// TODO: Can this be cached some how
List<FluidStack> representations = new ArrayList<>();
for (Fluid fluid : TagResolverHelper.getRepresentations(tag))
{
representations.add(new FluidStack(fluid, amount));
}
return representations;
}
@Override
public void write(PacketBuffer buffer)
{
buffer.writeEnumValue(IngredientType.TAGGED);
buffer.writeResourceLocation(TagCollectionManager.getManager().getFluidTags().getValidatedIdFromTag(tag));
buffer.writeVarInt(amount);
}
@Nonnull
@Override
public JsonElement serialize()
{
JsonObject json = new JsonObject();
json.addProperty(Constants.JSON.AMOUNT, amount);
json.addProperty(Constants.JSON.TAG, TagCollectionManager.getManager().getFluidTags().getValidatedIdFromTag(tag).toString());
return json;
}
public static Tagged read(PacketBuffer buffer)
{
return new Tagged(FluidTags.makeWrapperTag(buffer.readResourceLocation().toString()), buffer.readVarInt());
}
}
public static class Multi extends FluidStackIngredient
{
private final FluidStackIngredient[] ingredients;
protected Multi(@Nonnull FluidStackIngredient... ingredients)
{
this.ingredients = ingredients;
}
@Override
public boolean test(@Nonnull FluidStack stack)
{
return Arrays.stream(ingredients).anyMatch(ingredient -> ingredient.test(stack));
}
@Override
public boolean testType(@Nonnull FluidStack stack)
{
return Arrays.stream(ingredients).anyMatch(ingredient -> ingredient.testType(stack));
}
@Nonnull
@Override
public FluidStack getMatchingInstance(@Nonnull FluidStack stack)
{
for (FluidStackIngredient ingredient : ingredients)
{
FluidStack matchingInstance = ingredient.getMatchingInstance(stack);
if (!matchingInstance.isEmpty())
{
return matchingInstance;
}
}
return FluidStack.EMPTY;
}
@Nonnull
@Override
public List<FluidStack> getRepresentations()
{
List<FluidStack> representations = new ArrayList<>();
for (FluidStackIngredient ingredient : ingredients)
{
representations.addAll(ingredient.getRepresentations());
}
return representations;
}
@Override
public void write(PacketBuffer buffer)
{
buffer.writeEnumValue(IngredientType.MULTI);
buffer.writeVarInt(ingredients.length);
for (FluidStackIngredient ingredient : ingredients)
{
ingredient.write(buffer);
}
}
@Nonnull
@Override
public JsonElement serialize()
{
JsonArray json = new JsonArray();
for (FluidStackIngredient ingredient : ingredients)
{
json.add(ingredient.serialize());
}
return json;
}
public static FluidStackIngredient read(PacketBuffer buffer)
{
FluidStackIngredient[] ingredients = new FluidStackIngredient[buffer.readVarInt()];
for (int i = 0; i < ingredients.length; i++)
{
ingredients[i] = FluidStackIngredient.read(buffer);
}
return createMulti(ingredients);
}
}
private enum IngredientType
{
SINGLE,
TAGGED,
MULTI
}
}

View file

@ -1,52 +0,0 @@
package wayoftime.bloodmagic.api.event.recipes;
import java.util.List;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import com.google.gson.JsonElement;
import net.minecraft.network.PacketBuffer;
public interface InputIngredient<TYPE> extends Predicate<TYPE>
{
/**
* Evaluates this predicate on the given argument, ignoring any size data.
*
* @param type the input argument
*
* @return {@code true} if the input argument matches the predicate, otherwise
* {@code false}
*/
boolean testType(@Nonnull TYPE type);
TYPE getMatchingInstance(TYPE type);
/**
* Primarily for JEI, a list of valid instances of the type
*
* @return List (empty means no valid registrations found and recipe is to be
* hidden)
*
* @apiNote Do not modify any of the values returned by the representations
*/
@Nonnull
List<TYPE> getRepresentations();
/**
* Writes this ingredient to a PacketBuffer.
*
* @param buffer The buffer to write to.
*/
void write(PacketBuffer buffer);
/**
* Serializes this ingredient to a JsonElement
*
* @return JsonElement representation of this ingredient.
*/
@Nonnull
JsonElement serialize();
}

View file

@ -1,32 +0,0 @@
package wayoftime.bloodmagic.api.event.recipes;
import java.util.Collections;
import java.util.List;
import net.minecraft.tags.ITag;
/**
* Copied from Mekanism, including the author's rant about tags.
*/
public class TagResolverHelper
{
public static <TYPE> List<TYPE> getRepresentations(ITag<TYPE> tag)
{
try
{
return tag.getAllElements();
} catch (IllegalStateException e)
{
// Why do tags have to be such an annoyance in 1.16
// This is needed so that we can ensure we give JEI an empty list of
// representations
// instead of crashing on the first run, as recipes get "initialized" before
// tags are
// done initializing, and we don't want to spam the log with errors. JEI and
// things
// still work fine regardless of this
return Collections.emptyList();
}
}
}

View file

@ -1,69 +0,0 @@
package wayoftime.bloodmagic.api.impl.recipe;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import wayoftime.bloodmagic.api.inventory.IgnoredIInventory;
public abstract class BloodMagicRecipe implements IRecipe<IgnoredIInventory>
{
private final ResourceLocation id;
protected BloodMagicRecipe(ResourceLocation id)
{
this.id = id;
}
/**
* Writes this recipe to a PacketBuffer.
*
* @param buffer The buffer to write to.
*/
public abstract void write(PacketBuffer buffer);
@Nonnull
@Override
public ResourceLocation getId()
{
return id;
}
@Override
public boolean matches(@Nonnull IgnoredIInventory inv, @Nonnull World world)
{
return true;
}
@Override
public boolean isDynamic()
{
// Note: If we make this non dynamic, we can make it show in vanilla's crafting
// book and also then obey the recipe locking.
// For now none of that works/makes sense in our concept so don't lock it
return true;
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull IgnoredIInventory inv)
{
return ItemStack.EMPTY;
}
@Override
public boolean canFit(int width, int height)
{
return true;
}
@Nonnull
@Override
public ItemStack getRecipeOutput()
{
return ItemStack.EMPTY;
}
}

View file

@ -1,145 +0,0 @@
package wayoftime.bloodmagic.api.impl.recipe;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.annotation.Nonnull;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import wayoftime.bloodmagic.api.event.recipes.FluidStackIngredient;
public abstract class RecipeARC extends BloodMagicRecipe
{
public static final int MAX_RANDOM_OUTPUTS = 3;
@Nonnull
private final Ingredient input;
@Nonnull
private final Ingredient arc_tool;
private final FluidStackIngredient inputFluid;
@Nonnull
private final ItemStack output;
private final FluidStack outputFluid;
private final List<Pair<ItemStack, Double>> addedItems;
protected RecipeARC(ResourceLocation id, Ingredient input, Ingredient arc_tool, FluidStackIngredient inputFluid, ItemStack output, FluidStack outputFluid)
{
this(id, input, arc_tool, inputFluid, output, new ArrayList<Pair<ItemStack, Double>>(), outputFluid);
}
protected RecipeARC(ResourceLocation id, Ingredient input, Ingredient arc_tool, FluidStackIngredient inputFluid, ItemStack output, List<Pair<ItemStack, Double>> addedItems, FluidStack outputFluid)
{
super(id);
this.input = input;
this.arc_tool = arc_tool;
this.inputFluid = inputFluid;
this.output = output;
this.addedItems = addedItems;
this.outputFluid = outputFluid;
}
public RecipeARC addRandomOutput(ItemStack stack, double chance)
{
if (addedItems.size() >= MAX_RANDOM_OUTPUTS)
{
return this;
}
addedItems.add(Pair.of(stack, chance));
return this;
}
@Nonnull
public final Ingredient getInput()
{
return input;
}
@Nonnull
public final Ingredient getTool()
{
return arc_tool;
}
public final FluidStackIngredient getFluidIngredient()
{
return inputFluid;
}
public final FluidStack getFluidOutput()
{
return outputFluid;
}
@Override
public final NonNullList<Ingredient> getIngredients()
{
NonNullList<Ingredient> list = NonNullList.create();
list.add(getInput());
list.add(getTool());
return list;
}
public List<ItemStack> getAllListedOutputs()
{
List<ItemStack> list = new ArrayList<ItemStack>();
list.add(output.copy());
for (Pair<ItemStack, Double> pair : addedItems)
{
list.add(pair.getLeft().copy());
}
return list;
}
public List<ItemStack> getAllOutputs(Random rand)
{
List<ItemStack> list = new ArrayList<ItemStack>();
list.add(output.copy());
for (Pair<ItemStack, Double> pair : addedItems)
{
if (rand.nextDouble() < pair.getRight())
list.add(pair.getLeft().copy());
}
return list;
}
@Override
public void write(PacketBuffer buffer)
{
input.write(buffer);
arc_tool.write(buffer);
buffer.writeItemStack(output);
buffer.writeInt(addedItems.size());
for (Pair<ItemStack, Double> pair : addedItems)
{
buffer.writeItemStack(pair.getLeft());
buffer.writeDouble(pair.getValue());
}
buffer.writeBoolean(inputFluid != null);
if (inputFluid != null)
{
inputFluid.write(buffer);
}
buffer.writeBoolean(outputFluid != null);
if (outputFluid != null)
{
outputFluid.writeToPacket(buffer);
}
}
}

View file

@ -1,67 +0,0 @@
package wayoftime.bloodmagic.api.inventory;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public final class IgnoredIInventory implements IInventory
{
public static final IgnoredIInventory INSTANCE = new IgnoredIInventory();
private IgnoredIInventory()
{
}
@Override
public int getSizeInventory()
{
return 0;
}
@Override
public boolean isEmpty()
{
return true;
}
@Override
public ItemStack getStackInSlot(int index)
{
return ItemStack.EMPTY;
}
@Override
public ItemStack decrStackSize(int index, int count)
{
return ItemStack.EMPTY;
}
@Override
public ItemStack removeStackFromSlot(int index)
{
return ItemStack.EMPTY;
}
@Override
public void setInventorySlotContents(int index, @Nonnull ItemStack stack)
{
}
@Override
public void markDirty()
{
}
@Override
public boolean isUsableByPlayer(@Nonnull PlayerEntity player)
{
return false;
}
@Override
public void clear()
{
}
}

View file

@ -1,23 +0,0 @@
package wayoftime.bloodmagic.api.providers;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import wayoftime.bloodmagic.api.text.IHasTextComponent;
import wayoftime.bloodmagic.api.text.IHasTranslationKey;
public interface IBaseProvider extends IHasTextComponent, IHasTranslationKey
{
ResourceLocation getRegistryName();
default String getName()
{
return getRegistryName().getPath();
}
@Override
default ITextComponent getTextComponent()
{
return new TranslationTextComponent(getTranslationKey());
}
}

View file

@ -1,32 +0,0 @@
package wayoftime.bloodmagic.api.providers;
import javax.annotation.Nonnull;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
public interface IEntityTypeProvider extends IBaseProvider
{
@Nonnull
EntityType<?> getEntityType();
@Override
default ResourceLocation getRegistryName()
{
return getEntityType().getRegistryName();
}
@Override
default ITextComponent getTextComponent()
{
return getEntityType().getName();
}
@Override
default String getTranslationKey()
{
return getEntityType().getTranslationKey();
}
}

View file

@ -1,8 +0,0 @@
package wayoftime.bloodmagic.api.text;
import net.minecraft.util.text.ITextComponent;
public interface IHasTextComponent
{
ITextComponent getTextComponent();
}

View file

@ -1,6 +0,0 @@
package wayoftime.bloodmagic.api.text;
public interface IHasTranslationKey
{
String getTranslationKey();
}