Merge apibutnotreally with the main packages
Do not consider anything outside of the true API safe to use. And even then, I'm changing things. Just wait. Please I beg you.
This commit is contained in:
parent
616c08094b
commit
2fecb427fd
399 changed files with 958 additions and 977 deletions
|
@ -0,0 +1,44 @@
|
|||
package WayofTime.bloodmagic.recipe;
|
||||
|
||||
import WayofTime.bloodmagic.iface.ICustomAlchemyConsumable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AlchemyTableCustomRecipe extends AlchemyTableRecipe {
|
||||
public AlchemyTableCustomRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableCustomRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableCustomRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
super(result, lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem() instanceof ICustomAlchemyConsumable) {
|
||||
return ((ICustomAlchemyConsumable) copyStack.getItem()).drainUseOnAlchemyCraft(copyStack);
|
||||
}
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package WayofTime.bloodmagic.recipe;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class AlchemyTableRecipe {
|
||||
protected ItemStack output = ItemStack.EMPTY;
|
||||
protected ArrayList<Object> input = new ArrayList<Object>();
|
||||
protected int lpDrained;
|
||||
protected int ticksRequired;
|
||||
protected int tierRequired;
|
||||
|
||||
public AlchemyTableRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
output = result.copy();
|
||||
this.lpDrained = lpDrained;
|
||||
this.ticksRequired = ticksRequired;
|
||||
this.tierRequired = tierRequired;
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid alchemy recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output of the recipe, sensitive to the input list provided.
|
||||
* If the input list does not technically match, the recipe should return
|
||||
* the default output.
|
||||
*
|
||||
* @param inputList
|
||||
* @return
|
||||
*/
|
||||
public ItemStack getRecipeOutput(List<ItemStack> inputList) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory. World and
|
||||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (ItemStack slot : checkedList) {
|
||||
if (!slot.isEmpty()) {
|
||||
boolean inRecipe = false;
|
||||
|
||||
for (Object aRequired : required) {
|
||||
boolean match = false;
|
||||
|
||||
if (aRequired instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) aRequired, slot, false);
|
||||
} else if (aRequired instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) aRequired).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(aRequired);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should
|
||||
* never manipulate the values in this array as it will effect the recipe
|
||||
* itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public List<Object> getInput() {
|
||||
return ImmutableList.copyOf(input);
|
||||
}
|
||||
|
||||
public ItemStack[] getRemainingItems(ItemStack[] inventory) {
|
||||
ItemStack[] ret = inventory.clone();
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = getContainerItem(inventory[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
|
||||
public int getLpDrained() {
|
||||
return lpDrained;
|
||||
}
|
||||
|
||||
public int getTicksRequired() {
|
||||
return ticksRequired;
|
||||
}
|
||||
|
||||
public int getTierRequired() {
|
||||
return tierRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("output", output)
|
||||
.append("input", input)
|
||||
.append("lpDrained", lpDrained)
|
||||
.append("ticksRequired", ticksRequired)
|
||||
.append("tierRequired", tierRequired)
|
||||
.append("recipeSize", getRecipeSize())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof AlchemyTableRecipe)) return false;
|
||||
|
||||
AlchemyTableRecipe that = (AlchemyTableRecipe) o;
|
||||
|
||||
if (lpDrained != that.lpDrained) return false;
|
||||
if (ticksRequired != that.ticksRequired) return false;
|
||||
if (tierRequired != that.tierRequired) return false;
|
||||
if (output != null ? !output.equals(that.output) : that.output != null) return false;
|
||||
return input != null ? input.equals(that.input) : that.input == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = output != null ? output.hashCode() : 0;
|
||||
result = 31 * result + (input != null ? input.hashCode() : 0);
|
||||
result = 31 * result + lpDrained;
|
||||
result = 31 * result + ticksRequired;
|
||||
result = 31 * result + tierRequired;
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package WayofTime.bloodmagic.recipe;
|
||||
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LivingArmourDowngradeRecipe {
|
||||
protected LivingArmourUpgrade upgrade = null;
|
||||
protected ItemStack keyStack = ItemStack.EMPTY;
|
||||
protected List<Object> input = new ArrayList<Object>();
|
||||
|
||||
public LivingArmourDowngradeRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) {
|
||||
this.upgrade = upgrade;
|
||||
this.keyStack = keyStack;
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid living armour downgrade recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += upgrade.toString();
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
public LivingArmourUpgrade getRecipeOutput() {
|
||||
return upgrade;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory. World and
|
||||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(ItemStack key, List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||
if (!OreDictionary.itemMatches(keyStack, key, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (ItemStack slot : checkedList) {
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
|
||||
for (Object aRequired : required) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = aRequired;
|
||||
|
||||
if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should
|
||||
* never manipulate the values in this array as it will effect the recipe
|
||||
* itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public List<Object> getInput() {
|
||||
return ImmutableList.copyOf(input);
|
||||
}
|
||||
|
||||
public ItemStack getKey() {
|
||||
return this.keyStack;
|
||||
}
|
||||
|
||||
public void consumeInventory(IItemHandler inv) {
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stack.getItem().hasContainerItem(stack)) {
|
||||
inv.extractItem(i, stack.getCount(), false);
|
||||
inv.insertItem(i, stack.getItem().getContainerItem(stack), false);
|
||||
} else {
|
||||
inv.extractItem(i, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package WayofTime.bloodmagic.recipe;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TartaricForgeRecipe {
|
||||
protected ItemStack output = null;
|
||||
protected List<Object> input = new ArrayList<Object>();
|
||||
protected double minimumSouls;
|
||||
protected double soulsDrained;
|
||||
|
||||
public TartaricForgeRecipe(Block result, double minSouls, double drain, Object... recipe) {
|
||||
this(new ItemStack(result), minSouls, drain, recipe);
|
||||
}
|
||||
|
||||
public TartaricForgeRecipe(Item result, double minSouls, double drain, Object... recipe) {
|
||||
this(new ItemStack(result), minSouls, drain, recipe);
|
||||
}
|
||||
|
||||
public TartaricForgeRecipe(ItemStack result, double minSouls, double drain, Object... recipe) {
|
||||
output = result.copy();
|
||||
this.minimumSouls = minSouls;
|
||||
this.soulsDrained = drain;
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid soul forge recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory. World and
|
||||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (int x = 0; x < checkedList.size(); x++) {
|
||||
ItemStack slot = checkedList.get(x);
|
||||
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
|
||||
while (req.hasNext()) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = req.next();
|
||||
|
||||
if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should
|
||||
* never manipulate the values in this array as it will effect the recipe
|
||||
* itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public List<Object> getInput() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public double getMinimumSouls() {
|
||||
return minimumSouls;
|
||||
}
|
||||
|
||||
public double getSoulsDrained() {
|
||||
return soulsDrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("output", output)
|
||||
.append("input", input)
|
||||
.append("minimumSouls", minimumSouls)
|
||||
.append("soulsDrained", soulsDrained)
|
||||
.append("recipeSize", getRecipeSize())
|
||||
.append("recipeOutput", getRecipeOutput())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof TartaricForgeRecipe)) return false;
|
||||
|
||||
TartaricForgeRecipe that = (TartaricForgeRecipe) o;
|
||||
|
||||
if (Double.compare(that.minimumSouls, minimumSouls) != 0) return false;
|
||||
if (Double.compare(that.soulsDrained, soulsDrained) != 0) return false;
|
||||
if (output != null ? !output.equals(that.output) : that.output != null) return false;
|
||||
return input != null ? input.equals(that.input) : that.input == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = output != null ? output.hashCode() : 0;
|
||||
result = 31 * result + (input != null ? input.hashCode() : 0);
|
||||
temp = Double.doubleToLongBits(minimumSouls);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(soulsDrained);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package WayofTime.bloodmagic.recipe.alchemyTable;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import WayofTime.bloodmagic.apibutnotreally.recipe.AlchemyTableRecipe;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import WayofTime.bloodmagic.recipe.AlchemyTableRecipe;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemBanner;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package WayofTime.bloodmagic.recipe.alchemyTable;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.recipe.AlchemyTableRecipe;
|
||||
import WayofTime.bloodmagic.recipe.AlchemyTableRecipe;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue