mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-27 23:45:57 +00:00
Getting close
This commit is contained in:
1 parent
fbbb4e3c02
commit
04900e560d
49 files changed
+241
-306
No files matched your search
@@ -37,6 +37,7 @@ import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.DummyMethodHandler;
|
||||
import vazkii.botania.api.internal.DummySubTile;
|
||||
@@ -100,7 +101,6 @@ public final class BotaniaAPI {
|
||||
public static final Set<Class<? extends Entity>> gravityRodBlacklist = new LinkedHashSet<>();
|
||||
public static final Set<Block> gaiaBreakBlacklist = new HashSet<>();
|
||||
|
||||
// TODO 1.13 move these to eliminate dependence on botania proper in Ingredients
|
||||
private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
|
||||
public static final IArmorMaterial MANASTEEL_ARMOR_MAT = new IArmorMaterial() {
|
||||
private final int[] damageReduction = { 2, 5, 6, 2 };
|
||||
@@ -126,7 +126,8 @@ public final class BotaniaAPI {
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(ModItems.manaSteel);
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,7 +169,8 @@ public final class BotaniaAPI {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(ModItems.manaSteel);
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -196,7 +198,8 @@ public final class BotaniaAPI {
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(ModItems.elementium);
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,7 +241,8 @@ public final class BotaniaAPI {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(ModItems.elementium);
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -266,7 +270,8 @@ public final class BotaniaAPI {
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(ModItems.terrasteel);
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "terrasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -308,7 +313,8 @@ public final class BotaniaAPI {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(ModItems.terrasteel);
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "terrasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
};
|
||||
public static final IArmorMaterial MANAWEAVE_ARMOR_MAT = new IArmorMaterial() {
|
||||
@@ -335,7 +341,8 @@ public final class BotaniaAPI {
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(ModItems.manaweaveCloth);
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manaweave_cloth"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -552,7 +559,7 @@ public final class BotaniaAPI {
|
||||
* or String (case for Ore Dictionary). The array can't be larger than 16.
|
||||
* @return The recipe created.
|
||||
*/
|
||||
public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) {
|
||||
public static RecipePetals registerPetalRecipe(ItemStack output, Ingredient... inputs) {
|
||||
Preconditions.checkArgument(inputs.length <= 16);
|
||||
RecipePetals recipe = new RecipePetals(output, inputs);
|
||||
petalRecipes.add(recipe);
|
||||
@@ -617,7 +624,7 @@ public final class BotaniaAPI {
|
||||
* Alchemy Catalyst below the pool).
|
||||
* @see BotaniaAPI#registerManaInfusionRecipe
|
||||
*/
|
||||
public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Object input, int mana) {
|
||||
public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Ingredient input, int mana) {
|
||||
RecipeManaInfusion recipe = registerManaInfusionRecipe(output, input, mana);
|
||||
recipe.setCatalyst(RecipeManaInfusion.alchemyState);
|
||||
return recipe;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class RecipeBrew {
|
||||
return inputsMissing.isEmpty();
|
||||
}
|
||||
|
||||
public List<Object> getInputs() {
|
||||
public List<Ingredient> getInputs() {
|
||||
return new ArrayList<>(inputs);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.api.recipe;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -23,67 +24,40 @@ import java.util.List;
|
||||
public class RecipePetals {
|
||||
|
||||
private final ItemStack output;
|
||||
private final ImmutableList<Object> inputs;
|
||||
private final ImmutableList<Ingredient> inputs;
|
||||
|
||||
public RecipePetals(ItemStack output, Object... inputs) {
|
||||
public RecipePetals(ItemStack output, Ingredient... inputs) {
|
||||
this.output = output;
|
||||
|
||||
ImmutableList.Builder<Object> inputsToSet = ImmutableList.builder();
|
||||
for(Object obj : inputs) {
|
||||
if(obj instanceof String || obj instanceof ItemStack)
|
||||
inputsToSet.add(obj);
|
||||
else throw new IllegalArgumentException("Invalid input");
|
||||
}
|
||||
|
||||
this.inputs = inputsToSet.build();
|
||||
this.inputs = ImmutableList.copyOf(inputs);
|
||||
}
|
||||
|
||||
public boolean matches(IItemHandler inv) {
|
||||
List<Object> inputsMissing = new ArrayList<>(inputs);
|
||||
List<Ingredient> ingredientsMissing = new ArrayList<>(inputs);
|
||||
|
||||
for(int i = 0; i < inv.getSlots(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if(stack.isEmpty())
|
||||
ItemStack input = inv.getStackInSlot(i);
|
||||
if(input.isEmpty())
|
||||
break;
|
||||
|
||||
int stackIndex = -1, oredictIndex = -1;
|
||||
int stackIndex = -1;
|
||||
|
||||
for(int j = 0; j < inputsMissing.size(); j++) {
|
||||
Object input = inputsMissing.get(j);
|
||||
if(input instanceof String) {
|
||||
boolean found = false;
|
||||
for(ItemStack ostack : OreDictionary.getOres((String) input, false)) {
|
||||
if(OreDictionary.itemMatches(ostack, stack, false)) {
|
||||
oredictIndex = j;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(found)
|
||||
break;
|
||||
} else if(input instanceof ItemStack && compareStacks((ItemStack) input, stack)) {
|
||||
for(int j = 0; j < ingredientsMissing.size(); j++) {
|
||||
Ingredient ingr = ingredientsMissing.get(j);
|
||||
if(ingr.test(input)) {
|
||||
stackIndex = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(stackIndex != -1)
|
||||
inputsMissing.remove(stackIndex);
|
||||
else if(oredictIndex != -1)
|
||||
inputsMissing.remove(oredictIndex);
|
||||
ingredientsMissing.remove(stackIndex);
|
||||
else return false;
|
||||
}
|
||||
|
||||
return inputsMissing.isEmpty();
|
||||
return ingredientsMissing.isEmpty();
|
||||
}
|
||||
|
||||
private boolean compareStacks(ItemStack recipe, ItemStack supplied) {
|
||||
return recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage() && ItemNBTHelper.isTagSubset(recipe.getTagCompound(), supplied.getTagCompound());
|
||||
}
|
||||
|
||||
public List<Object> getInputs() {
|
||||
public List<Ingredient> getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
package vazkii.botania.api.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
||||
public class RecipeRuneAltar extends RecipePetals {
|
||||
|
||||
private final int mana;
|
||||
|
||||
public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) {
|
||||
public RecipeRuneAltar(ItemStack output, int mana, Ingredient... inputs) {
|
||||
super(output, inputs);
|
||||
this.mana = mana;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user