Skip to content

Commit

Permalink
Update for Forestry 4; Forestry-Dev.jar is now included via gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
Voidi committed Oct 14, 2015
1 parent cd2780a commit 33de76b
Show file tree
Hide file tree
Showing 10 changed files with 463 additions and 455 deletions.
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ minecraft {
runDir = "eclipse"
}

repositories {
maven {
name = "forestry"
url = "http://maven.ic2.player.to/"
}
}

dependencies {
compile "net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}:dev"
}

processResources
{
// this will ensure that this task is redone when the versions change.
Expand Down
2 changes: 2 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ minecraft.version=1.7.10
forge.version=10.13.4.1448-1.7.10

mod.version=0.9.4

forestry.version=4.0.8.36
20 changes: 11 additions & 9 deletions src/main/java/modtweaker2/mods/forestry/ForestryHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import forestry.factory.gadgets.MachineCarpenter;
import forestry.factory.tiles.TileCarpenter;

public class ForestryHelper {

@SuppressWarnings("unchecked")
public static void addCarpenterRecipeBox(ItemStack box) {
ArrayList<ItemStack> recipeBoxes = (ArrayList<ItemStack>) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "boxes");
if(recipeBoxes != null) {
recipeBoxes.add(box);
}
List<ItemStack> recipeBoxes = (ArrayList<ItemStack>) ReflectionHelper.getStaticObject(TileCarpenter.RecipeManager.class, "boxes");

if(recipeBoxes != null) {
recipeBoxes.add(box);
}
}

@SuppressWarnings("unchecked")
public static void addCarpenterRecipeFluids(Fluid newFluid) {
HashSet<Fluid> recipeFluids = (HashSet<Fluid>) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "recipeFluids");
Set<Fluid> recipeFluids = (HashSet<Fluid>) ReflectionHelper.getStaticObject(TileCarpenter.RecipeManager.class, "recipeFluids");

if(recipeFluids != null) {
recipeFluids.add(newFluid);
recipeFluids.add(newFluid);
}
}
}
62 changes: 30 additions & 32 deletions src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.core.utils.ShapedRecipeCustom;
import forestry.factory.gadgets.MachineCarpenter;
import forestry.factory.gadgets.MachineCarpenter.Recipe;
import forestry.factory.gadgets.MachineCarpenter.RecipeManager;
import forestry.core.recipes.ShapedRecipeCustom;
import forestry.factory.tiles.TileCarpenter;
import forestry.factory.tiles.TileCarpenter.Recipe;
import forestry.factory.tiles.TileCarpenter.RecipeManager;

@ZenClass("mods.forestry.Carpenter")
public class Carpenter {
public static final String name = "Forestry Carpenter";
public static final String name = "Forestry Carpenter";

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
* Adds a shaped recipe for the Carpenter
Expand Down Expand Up @@ -83,7 +83,7 @@ public static void addRecipe(int packagingTime, ILiquidStack liquid, IItemStack[
private static class Add extends BaseListAddition<Recipe> {

public Add(Recipe recipe) {
super(Carpenter.name, MachineCarpenter.RecipeManager.recipes);
super(Carpenter.name, TileCarpenter.RecipeManager.recipes);
recipes.add(recipe);

// The Carpenter has a list of valid Fluids, access them via
Expand All @@ -98,12 +98,12 @@ public Add(Recipe recipe) {

@Override
protected String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
* Removes a recipe for the Carpenter
*
Expand All @@ -112,37 +112,35 @@ protected String getRecipeInfo(Recipe recipe) {
*/
@ZenMethod
public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) {
List<Recipe> recipes = new LinkedList<Recipe>();

for(Recipe recipe : RecipeManager.recipes) {
if( recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult())) ) {
if (liquid != null) {
if (matches(liquid, toILiquidStack(recipe.getLiquid())))
recipes.add(recipe);
} else {
recipes.add(recipe);
}
}
}

if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString()));
}

List<Recipe> recipes = new LinkedList<Recipe>();

for(Recipe recipe : RecipeManager.recipes) {
if( recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult())) ) {
if (liquid != null) {
if (matches(liquid, toILiquidStack(recipe.getLiquid())))
recipes.add(recipe);
} else {
recipes.add(recipe);
}
}
}

if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString()));
}
}

private static class Remove extends BaseListRemoval<Recipe> {

public Remove(List<Recipe> recipes) {
super(Carpenter.name, RecipeManager.recipes, recipes);
}

@Override
protected String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
83 changes: 41 additions & 42 deletions src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.api.recipes.ICentrifugeRecipe;
import forestry.factory.gadgets.MachineCentrifuge.CentrifugeRecipe;
import forestry.factory.gadgets.MachineCentrifuge.RecipeManager;
import forestry.factory.tiles.TileCentrifuge.CentrifugeRecipe;
import forestry.factory.tiles.TileCentrifuge.RecipeManager;


@ZenClass("mods.forestry.Centrifuge")
public class Centrifuge {

public static final String name = "Forestry Centrifuge";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static final String name = "Forestry Centrifuge";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a recipe for the Centrifuge
*
Expand All @@ -46,7 +46,7 @@ public static void addRecipe(WeightedItemStack[] output, IItemStack ingredient,
}
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(ingredient), products)));
}

@ZenMethod
@Deprecated
public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) {
Expand All @@ -58,53 +58,52 @@ public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[]
}
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products)));
}

private static class Add extends BaseListAddition<ICentrifugeRecipe> {

public Add(ICentrifugeRecipe recipe) {
super(Centrifuge.name, RecipeManager.recipes);
recipes.add(recipe);
}

@Override
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


private static class Add extends BaseListAddition<ICentrifugeRecipe> {
public Add(ICentrifugeRecipe recipe) {
super(Centrifuge.name, RecipeManager.recipes);
recipes.add(recipe);
}

@Override
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
* Removes a recipe for the Centrifuge
*
* @param ingredient item input
* @param input item input
*/
@ZenMethod
public static void removeRecipe(IIngredient input) {
List<ICentrifugeRecipe> recipes = new LinkedList<ICentrifugeRecipe>();
for(ICentrifugeRecipe recipe : RecipeManager.recipes) {
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString()));
}
List<ICentrifugeRecipe> recipes = new LinkedList<ICentrifugeRecipe>();
for(ICentrifugeRecipe recipe : RecipeManager.recipes) {
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString()));
}
}

private static class Remove extends BaseListRemoval<ICentrifugeRecipe> {

public Remove(List<ICentrifugeRecipe> recipes) {
super(Centrifuge.name, RecipeManager.recipes, recipes);
}

@Override
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
return LogHelper.getStackDescription(recipe.getInput());
}
}
}
Loading

0 comments on commit 33de76b

Please sign in to comment.