mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 15:33:12 +00:00
Add CraftTweaker Support for Extra Trees Machines
This commit is contained in:
1 parent
dbdb5478c2
commit
21728bcab1
30 files changed
+768
-18
No files matched your search
+6
-1
@@ -52,17 +52,22 @@ repositories {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
maven {
|
||||
name "Jared"
|
||||
url "http://maven.blamejared.com/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile("net.sengir.forestry:forestry_${mcversion}:${forestry_version}") {
|
||||
transitive = false;
|
||||
transitive = false
|
||||
}
|
||||
deobfProvided "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
runtime "jei-bees:jeibees:${jeibees_version}:mc${mcversion}"
|
||||
deobfProvided "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
runtime "net.industrial-craft:industrialcraft-2:${ic2_version}"
|
||||
deobfProvided "MineTweaker3:MineTweaker3-API:${minetweaker_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
@@ -16,3 +16,4 @@ version_patch=0
|
||||
|
||||
jei_version=4.5.0.292
|
||||
jeibees_version=0.9.0.5
|
||||
minetweaker_version=3.0.26.113
|
||||
@@ -146,7 +146,7 @@ public class Botany extends AbstractMod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
public boolean isAvailable() {
|
||||
return BinnieCore.isBotanyActive();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
|
||||
protected abstract void registerModules();
|
||||
|
||||
public abstract boolean isActive();
|
||||
public abstract boolean isAvailable();
|
||||
|
||||
@Override
|
||||
public abstract String getChannel();
|
||||
@@ -69,7 +69,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
@Override
|
||||
public void preInit() {
|
||||
getProxy().setMod(this);
|
||||
if (!this.isActive()) {
|
||||
if (!this.isAvailable()) {
|
||||
disabledSetupAPI();
|
||||
return;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (!this.isActive()) {
|
||||
if (!this.isAvailable()) {
|
||||
disabledSetupAPI();
|
||||
return;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
if (!this.isActive()) {
|
||||
if (!this.isAvailable()) {
|
||||
disabledSetupAPI();
|
||||
return;
|
||||
}
|
||||
@@ -113,7 +113,10 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
protected final void addModule(final IInitializable init) {
|
||||
protected final void addModule(IInitializable init) {
|
||||
if(!init.isAvailable()) {
|
||||
return;
|
||||
}
|
||||
this.modules.add(init);
|
||||
MinecraftForge.EVENT_BUS.register(init);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public final class BinnieCore extends AbstractMod {
|
||||
private static List<AbstractMod> getActiveMods() {
|
||||
final List<AbstractMod> list = new ArrayList<>();
|
||||
for (final AbstractMod mod : BinnieCore.modList) {
|
||||
if (mod.isActive()) {
|
||||
if (mod.isAvailable()) {
|
||||
list.add(mod);
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ public final class BinnieCore extends AbstractMod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,13 @@ public interface IInitializable {
|
||||
|
||||
void postInit();
|
||||
|
||||
/**
|
||||
* For compat modules if the mod is not loaded the module will not be registered.
|
||||
*/
|
||||
default boolean isAvailable(){
|
||||
return true;
|
||||
}
|
||||
|
||||
default void setupAPI(){
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
package binnie.core.api;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IBinnieRecipe {
|
||||
|
||||
Collection<Object> getInputs();
|
||||
|
||||
Collection<Object> getOutputs();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.core.api;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ICraftingManager<T extends IBinnieRecipe> {
|
||||
@@ -21,4 +22,13 @@ public interface ICraftingManager<T extends IBinnieRecipe> {
|
||||
* @return an unmodifiable collection of all recipes registered to the crafting provider.
|
||||
*/
|
||||
Collection<T> recipes();
|
||||
|
||||
/**
|
||||
* @return null if this type of recipe has no jei integration
|
||||
*/
|
||||
@Nullable
|
||||
String getJEICategory();
|
||||
|
||||
@Nullable
|
||||
Object getJeiWrapper(T recipe);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package binnie.core.util;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FluidStackUtil {
|
||||
|
||||
public static String toString(FluidStack fluidStack){
|
||||
if(fluidStack == null){
|
||||
return "null";
|
||||
}
|
||||
NBTTagCompound tag = fluidStack.tag;
|
||||
return fluidStack.getFluid().getName() + ":" + fluidStack.amount + (tag != null ? ":" + fluidStack.tag : "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package binnie.core.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ItemStackUtil {
|
||||
|
||||
public static boolean isItemEqual(ItemStack a, ItemStack b, boolean matchDamage, boolean matchNBT) {
|
||||
if (a.isEmpty() || b.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (a.getItem() != b.getItem()) {
|
||||
return false;
|
||||
}
|
||||
if (matchDamage && a.getHasSubtypes()) {
|
||||
if (a.getItemDamage() == OreDictionary.WILDCARD_VALUE || b.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
return true;
|
||||
}
|
||||
if (a.getItemDamage() != b.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !matchNBT || ItemStack.areItemStackTagsEqual(a, b);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import binnie.extratrees.core.ModuleCore;
|
||||
import binnie.extratrees.genetics.ETTreeDefinition;
|
||||
import binnie.extratrees.genetics.FruitSprite;
|
||||
import binnie.extratrees.genetics.ModuleGenetics;
|
||||
import binnie.extratrees.integration.crafttweaker.CraftTweakerModule;
|
||||
import binnie.extratrees.item.ModuleItems;
|
||||
import binnie.extratrees.kitchen.ModuleKitchen;
|
||||
import binnie.extratrees.machines.DummyManagers;
|
||||
@@ -147,6 +148,7 @@ public class ExtraTrees extends AbstractMod {
|
||||
this.addModule(machine = new ModuleMachine());
|
||||
this.addModule(new ModuleCore());
|
||||
this.addModule(kitchen = new ModuleKitchen());
|
||||
this.addModule(new CraftTweakerModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,7 +198,7 @@ public class ExtraTrees extends AbstractMod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
public boolean isAvailable() {
|
||||
return BinnieCore.isExtraTreesActive();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package binnie.extratrees.integration.crafttweaker;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import binnie.core.IInitializable;
|
||||
import binnie.extratrees.integration.crafttweaker.handlers.BreweryRecipeHandler;
|
||||
import binnie.extratrees.integration.crafttweaker.handlers.DistilleryRecipeHandler;
|
||||
import binnie.extratrees.integration.crafttweaker.handlers.FruitPressRecipeHandler;
|
||||
import binnie.extratrees.integration.crafttweaker.handlers.LumbermillRecipeHandler;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
public class CraftTweakerModule implements IInitializable {
|
||||
public static final String MOD_ID = "crafttweaker";
|
||||
|
||||
public void init(){
|
||||
initCT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "crafttweaker")
|
||||
private void initCT(){
|
||||
MineTweakerAPI.registerClass(BreweryRecipeHandler.class);
|
||||
MineTweakerAPI.registerClass(DistilleryRecipeHandler.class);
|
||||
MineTweakerAPI.registerClass(FruitPressRecipeHandler.class);
|
||||
MineTweakerAPI.registerClass(LumbermillRecipeHandler.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return Loader.isModLoaded(MOD_ID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package binnie.extratrees.integration.crafttweaker;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
|
||||
public class CraftTweakerUtil {
|
||||
|
||||
public static ItemStack getItemStack(IIngredient item) {
|
||||
if(item == null)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
Object internal = item.getInternal();
|
||||
if(internal == null || !(internal instanceof ItemStack)) {
|
||||
MineTweakerAPI.logError("Not a valid item stack: " + item);
|
||||
}
|
||||
return (ItemStack) internal;
|
||||
}
|
||||
|
||||
public static FluidStack getLiquidStack(IIngredient stack) {
|
||||
if(stack == null || !(stack.getInternal() instanceof FluidStack))
|
||||
return null;
|
||||
|
||||
return (FluidStack) stack.getInternal();
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package binnie.extratrees.integration.crafttweaker.handlers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.extratrees.api.recipes.ExtraTreesRecipeManager;
|
||||
import binnie.extratrees.integration.crafttweaker.CraftTweakerUtil;
|
||||
import binnie.extratrees.item.ExtraTreeItems;
|
||||
import binnie.extratrees.machines.brewery.recipes.BrewedGrainRecipe;
|
||||
import binnie.extratrees.machines.brewery.recipes.BreweryRecipe;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.oredict.IOreDictEntry;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.extratrees.Brewery")
|
||||
public class BreweryRecipeHandler extends GenericRecipeHandler {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack input, ILiquidStack output, @Optional IItemStack yeast){
|
||||
FluidStack inputStack = CraftTweakerUtil.getLiquidStack(input);
|
||||
FluidStack outputStack = CraftTweakerUtil.getLiquidStack(output);
|
||||
ItemStack yeastStack = ExtraTreeItems.Yeast.get(1);
|
||||
if(yeast != null) {
|
||||
yeastStack = CraftTweakerUtil.getItemStack(yeast);
|
||||
}
|
||||
addRecipe(new BreweryRecipe(inputStack, outputStack, yeastStack), ExtraTreesRecipeManager.breweryManager);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addGrainRecipe(IOreDictEntry grainOreName, ILiquidStack output, @Optional IOreDictEntry ingredientOreName, @Optional IItemStack yeast){
|
||||
FluidStack outputStack = CraftTweakerUtil.getLiquidStack(output);
|
||||
ItemStack yeastStack = ExtraTreeItems.Yeast.get(1);
|
||||
if(yeast != null) {
|
||||
yeastStack = CraftTweakerUtil.getItemStack(yeast);
|
||||
}
|
||||
addRecipe(new BrewedGrainRecipe(outputStack, grainOreName.getName(), ingredientOreName.getName(), yeastStack), ExtraTreesRecipeManager.breweryManager);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(IIngredient ingredient){
|
||||
if(ingredient instanceof IItemStack){
|
||||
removeRecipe(CraftTweakerUtil.getItemStack(ingredient), ExtraTreesRecipeManager.breweryManager);
|
||||
}else if(ingredient instanceof ILiquidStack){
|
||||
removeRecipe(CraftTweakerUtil.getLiquidStack(ingredient), ExtraTreesRecipeManager.breweryManager);
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeInput(IIngredient ingredient){
|
||||
if(ingredient instanceof IItemStack){
|
||||
removeRecipeInput(CraftTweakerUtil.getItemStack(ingredient), ExtraTreesRecipeManager.breweryManager);
|
||||
}else if(ingredient instanceof ILiquidStack){
|
||||
removeRecipeInput(CraftTweakerUtil.getLiquidStack(ingredient), ExtraTreesRecipeManager.breweryManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package binnie.extratrees.integration.crafttweaker.handlers;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.extratrees.api.recipes.ExtraTreesRecipeManager;
|
||||
import binnie.extratrees.integration.crafttweaker.CraftTweakerUtil;
|
||||
import binnie.extratrees.machines.distillery.recipes.DistilleryRecipe;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.extratrees.Distillery")
|
||||
public class DistilleryRecipeHandler extends GenericRecipeHandler {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack input, ILiquidStack output, int level){
|
||||
FluidStack inputStack = CraftTweakerUtil.getLiquidStack(input);
|
||||
FluidStack outputStack = CraftTweakerUtil.getLiquidStack(output);
|
||||
addRecipe(new DistilleryRecipe(inputStack, outputStack, level), ExtraTreesRecipeManager.distilleryManager);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(IIngredient ingredient){
|
||||
removeRecipe(CraftTweakerUtil.getLiquidStack(ingredient), ExtraTreesRecipeManager.distilleryManager);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeInput(IIngredient ingredient){
|
||||
removeRecipeInput(CraftTweakerUtil.getLiquidStack(ingredient), ExtraTreesRecipeManager.distilleryManager);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package binnie.extratrees.integration.crafttweaker.handlers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.extratrees.api.recipes.ExtraTreesRecipeManager;
|
||||
import binnie.extratrees.integration.crafttweaker.CraftTweakerUtil;
|
||||
import binnie.extratrees.machines.fruitpress.recipes.FruitPressRecipe;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.extratrees.FruitPress")
|
||||
public class FruitPressRecipeHandler extends GenericRecipeHandler {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, ILiquidStack output){
|
||||
ItemStack inputStack = CraftTweakerUtil.getItemStack(input);
|
||||
FluidStack outputStack = CraftTweakerUtil.getLiquidStack(output);
|
||||
addRecipe(new FruitPressRecipe(inputStack, outputStack), ExtraTreesRecipeManager.fruitPressManager);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(IIngredient ingredient){
|
||||
if(ingredient instanceof ILiquidStack){
|
||||
removeRecipe(CraftTweakerUtil.getLiquidStack(ingredient), ExtraTreesRecipeManager.fruitPressManager);
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeInput(IIngredient ingredient){
|
||||
if(ingredient instanceof IItemStack){
|
||||
removeRecipeInput(CraftTweakerUtil.getItemStack(ingredient), ExtraTreesRecipeManager.fruitPressManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
package binnie.extratrees.integration.crafttweaker.handlers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.api.IBinnieRecipe;
|
||||
import binnie.core.api.ICraftingManager;
|
||||
import binnie.core.util.ItemStackUtil;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
public class GenericRecipeHandler {
|
||||
|
||||
public static <R extends IBinnieRecipe, M extends ICraftingManager<R>> void removeRecipe(ItemStack output, M manager) {
|
||||
Collection<R> recipes = manager.recipes();
|
||||
List<R> recipeToRemove = new LinkedList<>();
|
||||
for(R recipe : recipes){
|
||||
for(Object o : recipe.getOutputs()){
|
||||
if(o instanceof ItemStack){
|
||||
ItemStack itemStack = (ItemStack) o;
|
||||
if(ItemStackUtil.isItemEqual(itemStack, output, true, false)){
|
||||
recipeToRemove.add(recipe);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MineTweakerAPI.apply(new Remove(recipeToRemove, manager));
|
||||
}
|
||||
|
||||
public static <R extends IBinnieRecipe, M extends ICraftingManager<R>> void removeRecipeInput(ItemStack input, M manager) {
|
||||
Collection<R> recipes = manager.recipes();
|
||||
List<R> recipeToRemove = new LinkedList<>();
|
||||
for(R recipe : recipes){
|
||||
for(Object o : recipe.getInputs()){
|
||||
if(o instanceof ItemStack){
|
||||
ItemStack itemStack = (ItemStack) o;
|
||||
if(ItemStackUtil.isItemEqual(itemStack, input, true, false)){
|
||||
recipeToRemove.add(recipe);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MineTweakerAPI.apply(new Remove(recipeToRemove, manager));
|
||||
}
|
||||
|
||||
public static <R extends IBinnieRecipe, M extends ICraftingManager<R>> void removeRecipe(FluidStack output, M manager) {
|
||||
Collection<R> recipes = manager.recipes();
|
||||
List<R> recipeToRemove = new LinkedList<>();
|
||||
for(R recipe : recipes){
|
||||
for(Object o : recipe.getOutputs()){
|
||||
if(o instanceof FluidStack){
|
||||
FluidStack fluidStack = (FluidStack) o;
|
||||
if(fluidStack.isFluidEqual(output)){
|
||||
recipeToRemove.add(recipe);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MineTweakerAPI.apply(new Remove(recipeToRemove, manager));
|
||||
}
|
||||
|
||||
public static <R extends IBinnieRecipe, M extends ICraftingManager<R>> void removeRecipeInput(FluidStack input, M manager) {
|
||||
Collection<R> recipes = manager.recipes();
|
||||
List<R> recipeToRemove = new LinkedList<>();
|
||||
for(R recipe : recipes){
|
||||
for(Object o : recipe.getInputs()){
|
||||
if(o instanceof FluidStack){
|
||||
FluidStack fluidStack = (FluidStack) o;
|
||||
if(fluidStack.isFluidEqual(input)){
|
||||
recipeToRemove.add(recipe);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MineTweakerAPI.apply(new Remove(recipeToRemove, manager));
|
||||
}
|
||||
|
||||
public static <R extends IBinnieRecipe, M extends ICraftingManager<R>> void addRecipe(R recipe, M manager) {
|
||||
MineTweakerAPI.apply(new Add(recipe, manager));
|
||||
}
|
||||
|
||||
private static class Add<R extends IBinnieRecipe, M extends ICraftingManager<R>> implements IUndoableAction {
|
||||
private final R recipe;
|
||||
private final M manager;
|
||||
|
||||
public Add(R recipe, M manager) {
|
||||
this.recipe = recipe;
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if(manager.addRecipe(recipe)) {
|
||||
Object recipeWrapper = manager.getJeiWrapper(recipe);
|
||||
if(recipeWrapper != null) {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipeWrapper, manager.getJEICategory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if(manager.removeRecipe(recipe)) {
|
||||
Object recipeWrapper = manager.getJeiWrapper(recipe);
|
||||
if(recipeWrapper != null) {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipeWrapper, manager.getJEICategory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing " + manager.toString() + " recipe for " + recipe.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding " + manager.toString() + " recipe for " + recipe.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove<R extends IBinnieRecipe, M extends ICraftingManager<R>> implements IUndoableAction {
|
||||
private final List<R> recipes;
|
||||
private final M manager;
|
||||
|
||||
public Remove(List<R> recipes, M manager) {
|
||||
this.recipes = recipes;
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Iterator<R> rIterator = recipes.iterator();
|
||||
while(rIterator.hasNext()) {
|
||||
R recipe = rIterator.next();
|
||||
if (manager.removeRecipe(recipe)) {
|
||||
Object recipeWrapper = manager.getJeiWrapper(recipe);
|
||||
if (recipeWrapper != null) {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipeWrapper, manager.getJEICategory());
|
||||
}
|
||||
}else{
|
||||
rIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for(R recipe : recipes) {
|
||||
if (manager.addRecipe(recipe)) {
|
||||
Object recipeWrapper = manager.getJeiWrapper(recipe);
|
||||
if (recipeWrapper != null) {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipeWrapper, manager.getJEICategory());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing " + manager.toString() + " recipe for " + recipes.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Adding " + manager.toString() + " recipe for " + recipes.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package binnie.extratrees.integration.crafttweaker.handlers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.extratrees.api.recipes.ExtraTreesRecipeManager;
|
||||
import binnie.extratrees.integration.crafttweaker.CraftTweakerUtil;
|
||||
import binnie.extratrees.machines.lumbermill.recipes.LumbermillRecipe;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.extratrees.Lumbermill")
|
||||
public class LumbermillRecipeHandler extends GenericRecipeHandler {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, IItemStack output){
|
||||
ItemStack inputStack = CraftTweakerUtil.getItemStack(input);
|
||||
ItemStack outputStack = CraftTweakerUtil.getItemStack(output);
|
||||
addRecipe(new LumbermillRecipe(inputStack, outputStack), ExtraTreesRecipeManager.lumbermillManager);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(IIngredient ingredient){
|
||||
if(ingredient instanceof IItemStack){
|
||||
removeRecipe(CraftTweakerUtil.getItemStack(ingredient), ExtraTreesRecipeManager.lumbermillManager);
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeInput(IIngredient ingredient){
|
||||
if(ingredient instanceof IItemStack){
|
||||
removeRecipeInput(CraftTweakerUtil.getItemStack(ingredient), ExtraTreesRecipeManager.lumbermillManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,18 @@ public class DummyManagers {
|
||||
public Set<T> recipes() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getJEICategory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getJeiWrapper(T recipe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyBreweryManager extends DummyCraftingManager<IBreweryRecipe> implements IBreweryManager {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package binnie.extratrees.machines.brewery.recipes;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,6 +15,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.liquid.ManagerLiquid;
|
||||
import binnie.core.util.FluidStackUtil;
|
||||
import binnie.core.util.OreDictionaryUtil;
|
||||
import binnie.extratrees.api.recipes.IBreweryCrafting;
|
||||
import binnie.extratrees.api.recipes.IBreweryRecipe;
|
||||
@@ -62,6 +67,20 @@ public class BrewedGrainRecipe implements IBreweryRecipe {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<Object> getInputs() {
|
||||
if(ingredientOreName == null) {
|
||||
return ImmutableList.of(grainOreName, yeast);
|
||||
}
|
||||
return ImmutableList.of(grainOreName, yeast, ingredientOreName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getOutputs() {
|
||||
return Collections.singleton(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIngredient(ItemStack itemStack) {
|
||||
if (itemStack.isEmpty()) {
|
||||
@@ -80,6 +99,9 @@ public class BrewedGrainRecipe implements IBreweryRecipe {
|
||||
|
||||
@Override
|
||||
public boolean isGrain(ItemStack itemStack) {
|
||||
if(itemStack.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
return OreDictionaryUtil.hasOreName(itemStack, grainOreName);
|
||||
}
|
||||
|
||||
@@ -92,4 +114,14 @@ public class BrewedGrainRecipe implements IBreweryRecipe {
|
||||
public ItemStack getYeast() {
|
||||
return yeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("grainOreName", grainOreName)
|
||||
.add("output", FluidStackUtil.toString(output))
|
||||
.add("ingredientOreName", ingredientOreName)
|
||||
.add("yeast", yeast)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package binnie.extratrees.machines.brewery.recipes;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.util.FluidStackUtil;
|
||||
import binnie.extratrees.api.recipes.IBreweryCrafting;
|
||||
import binnie.extratrees.api.recipes.IBreweryRecipe;
|
||||
|
||||
@@ -40,6 +45,16 @@ public class BreweryRecipe implements IBreweryRecipe {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getInputs() {
|
||||
return ImmutableList.of(input, yeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getOutputs() {
|
||||
return Collections.singleton(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getInput() {
|
||||
return this.input;
|
||||
@@ -74,4 +89,13 @@ public class BreweryRecipe implements IBreweryRecipe {
|
||||
public ItemStack getYeast() {
|
||||
return yeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("input", FluidStackUtil.toString(input))
|
||||
.add("output", FluidStackUtil.toString(output))
|
||||
.add("yeast", yeast)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,13 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import binnie.extratrees.api.recipes.IBreweryManager;
|
||||
import binnie.extratrees.api.recipes.IBreweryRecipe;
|
||||
import binnie.extratrees.integration.jei.RecipeUids;
|
||||
import binnie.extratrees.integration.jei.brewery.BreweryRecipeWrapper;
|
||||
import binnie.extratrees.item.ExtraTreeItems;
|
||||
|
||||
public class BreweryRecipeManager implements IBreweryManager {
|
||||
@@ -143,4 +148,28 @@ public class BreweryRecipeManager implements IBreweryManager {
|
||||
return recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Brewery";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory() {
|
||||
return RecipeUids.BREWING;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getJeiWrapper(IBreweryRecipe recipe) {
|
||||
if(!Loader.isModLoaded("jei")){
|
||||
return null;
|
||||
}
|
||||
return getWrapper(recipe);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "jei")
|
||||
private Object getWrapper(IBreweryRecipe recipe){
|
||||
return new BreweryRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package binnie.extratrees.machines.distillery.recipes;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.util.FluidStackUtil;
|
||||
import binnie.extratrees.api.recipes.IDistilleryRecipe;
|
||||
|
||||
public class DistilleryRecipe implements IDistilleryRecipe {
|
||||
@@ -25,8 +31,28 @@ public class DistilleryRecipe implements IDistilleryRecipe {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getInputs() {
|
||||
return Collections.singleton(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getOutputs() {
|
||||
return Collections.singleton(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("input", FluidStackUtil.toString(input))
|
||||
.add("output", FluidStackUtil.toString(output))
|
||||
.add("level", level)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
+24
@@ -11,8 +11,13 @@ import java.util.Map;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import binnie.extratrees.api.recipes.IDistilleryManager;
|
||||
import binnie.extratrees.api.recipes.IDistilleryRecipe;
|
||||
import binnie.extratrees.integration.jei.RecipeUids;
|
||||
import binnie.extratrees.integration.jei.distillery.DistilleryRecipeWrapper;
|
||||
|
||||
public class DistilleryRecipeManager implements IDistilleryManager {
|
||||
private static final int LEVELS = 3;
|
||||
@@ -88,4 +93,23 @@ public class DistilleryRecipeManager implements IDistilleryManager {
|
||||
public Collection<IDistilleryRecipe> recipes() {
|
||||
return recipeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory() {
|
||||
return RecipeUids.DISTILLING;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getJeiWrapper(IDistilleryRecipe recipe) {
|
||||
if(!Loader.isModLoaded("jei")){
|
||||
return null;
|
||||
}
|
||||
return getWrapper(recipe);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "jei")
|
||||
private Object getWrapper(IDistilleryRecipe recipe){
|
||||
return new DistilleryRecipeWrapper(recipe.getLevel(), recipe.getInput(), recipe.getOutput());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package binnie.extratrees.machines.fruitpress.recipes;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.util.FluidStackUtil;
|
||||
import binnie.extratrees.api.recipes.IFruitPressRecipe;
|
||||
|
||||
public class FruitPressRecipe implements IFruitPressRecipe{
|
||||
@@ -24,4 +30,22 @@ public class FruitPressRecipe implements IFruitPressRecipe{
|
||||
public ItemStack getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getInputs() {
|
||||
return Collections.singleton(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getOutputs() {
|
||||
return Collections.singleton(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("input", input)
|
||||
.add("output", FluidStackUtil.toString(output))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
+23
@@ -11,8 +11,12 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import binnie.extratrees.api.recipes.IFruitPressManager;
|
||||
import binnie.extratrees.api.recipes.IFruitPressRecipe;
|
||||
import binnie.extratrees.integration.jei.RecipeUids;
|
||||
|
||||
public class FruitPressRecipeManager implements IFruitPressManager {
|
||||
//Map<input fruit item, Pair<input fruit, output fluid>>
|
||||
@@ -61,4 +65,23 @@ public class FruitPressRecipeManager implements IFruitPressManager {
|
||||
public Collection<IFruitPressRecipe> recipes() {
|
||||
return recipes.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory() {
|
||||
return RecipeUids.FRUIT_PRESS;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getJeiWrapper(IFruitPressRecipe recipe) {
|
||||
if(!Loader.isModLoaded("jei")){
|
||||
return null;
|
||||
}
|
||||
return getWrapper(recipe);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "jei")
|
||||
private Object getWrapper(IFruitPressRecipe recipe){
|
||||
return new FruitPressRecipe(recipe.getInput(), recipe.getOutput());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package binnie.extratrees.machines.lumbermill.recipes;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.extratrees.api.recipes.ILumbermillRecipe;
|
||||
@@ -22,4 +27,23 @@ public class LumbermillRecipe implements ILumbermillRecipe {
|
||||
public ItemStack getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getInputs() {
|
||||
return Collections.singleton(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getOutputs() {
|
||||
return Collections.singleton(output);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("input", input)
|
||||
.add("output", output)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
+25
@@ -3,6 +3,7 @@ package binnie.extratrees.machines.lumbermill.recipes;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -16,10 +17,15 @@ import net.minecraft.util.NonNullList;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import binnie.core.util.FakeCraftingWorld;
|
||||
import binnie.core.util.OreDictionaryUtil;
|
||||
import binnie.extratrees.api.recipes.ILumbermillManager;
|
||||
import binnie.extratrees.api.recipes.ILumbermillRecipe;
|
||||
import binnie.extratrees.integration.jei.RecipeUids;
|
||||
import binnie.extratrees.integration.jei.lumbermill.LumbermillRecipeWrapper;
|
||||
|
||||
public class LumbermillRecipeManager implements ILumbermillManager {
|
||||
//Map<input log item, Pair<input log, output planks>>
|
||||
@@ -103,6 +109,25 @@ public class LumbermillRecipeManager implements ILumbermillManager {
|
||||
return recipes.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory() {
|
||||
return RecipeUids.LUMBERMILL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getJeiWrapper(ILumbermillRecipe recipe) {
|
||||
if(!Loader.isModLoaded("jei")){
|
||||
return null;
|
||||
}
|
||||
return getWrapper(recipe);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "jei")
|
||||
private Object getWrapper(ILumbermillRecipe recipe){
|
||||
return new LumbermillRecipeWrapper(recipe.getInput(), recipe.getOutput());
|
||||
}
|
||||
|
||||
private static class FakeCraftingHandler extends Container {
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventoryIn) {
|
||||
|
||||
@@ -17,13 +17,8 @@ public class SlotValidatorLog extends SlotValidator {
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
int[] oreIDs = OreDictionary.getOreIDs(itemStack);
|
||||
for (int oreId : oreIDs) {
|
||||
if (oreId == logWoodId && LumbermillRecipeManager.getPlankProduct(itemStack) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
ItemStack plank = LumbermillRecipeManager.getPlankProduct(itemStack);
|
||||
return !plank.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -129,7 +129,7 @@ public class Genetics extends AbstractMod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
public boolean isAvailable() {
|
||||
return BinnieCore.isGeneticsActive();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user