mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-12 00:07:57 +00:00
[FRSTRY@1.7.10-3.3.0.452-unstable] { Issue #35 } Use Reflection to add boxes to carpenter
This commit is contained in:
1 parent
4a5f4d62ba
commit
72590e79f5
4 files changed
+39
-7
No files matched your search
@@ -5,7 +5,7 @@ import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import modtweaker.commands.EntityMappingLogger;
|
||||
import modtweaker.mods.botania.commands.BotaniaBrewLogger;
|
||||
import modtweaker.mods.botania.commands.BotaniaOrchidLogger;
|
||||
import modtweaker.mods.botania.commands.BotaniaOrechidLogger;
|
||||
import modtweaker.mods.botania.lexicon.commands.LexiconCategoryLogger;
|
||||
import modtweaker.mods.botania.lexicon.commands.LexiconEntryLogger;
|
||||
import modtweaker.mods.botania.lexicon.commands.LexiconKnowledgeTypesLogger;
|
||||
@@ -48,7 +48,7 @@ public class Commands {
|
||||
MineTweakerAPI.server.addMineTweakerCommand("lexiconPages", new String[] { "/minetweaker lexiconPages", "/minetweaker lexiconPages [ENTRY]", " Outputs a list of lexicon pages for the entry" }, new LexiconPageLogger());
|
||||
MineTweakerAPI.server.addMineTweakerCommand("botaniaBrews", new String[] { "/minetweaker botaniaBrews", " Outputs a list of keys for botania brews" }, new BotaniaBrewLogger());
|
||||
MineTweakerAPI.server.addMineTweakerCommand("lexiconKnowledgeTypes", new String[] { "/minetweaker lexiconKnowledgeTypes", " Outputs a list of keys for lexicon knowledge types" }, new LexiconKnowledgeTypesLogger());
|
||||
MineTweakerAPI.server.addMineTweakerCommand("botaniaOrchid", new String[] { "/minetweaker botaniaOrchid", " Outputs a list of keys for botania orchid weights" }, new BotaniaOrchidLogger());
|
||||
MineTweakerAPI.server.addMineTweakerCommand("botaniaOrchid", new String[] { "/minetweaker botaniaOrechid", " Outputs a list of keys for botania orechid weights" }, new BotaniaOrechidLogger());
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -11,15 +11,15 @@ import minetweaker.api.server.ICommandFunction;
|
||||
import modtweaker.mods.botania.BotaniaHelper;
|
||||
import net.minecraft.entity.EntityList;
|
||||
|
||||
public class BotaniaOrchidLogger implements ICommandFunction {
|
||||
public class BotaniaOrechidLogger implements ICommandFunction {
|
||||
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
|
||||
Set<String> keys = BotaniaAPI.oreWeights.keySet();
|
||||
System.out.println("Orchid Keys: " + keys.size());
|
||||
System.out.println("Orechid Keys: " + keys.size());
|
||||
for (String str : BotaniaAPI.oreWeights.keySet()) {
|
||||
System.out.println("Orchid Key: " + str);
|
||||
System.out.println("Orechid Key: " + str);
|
||||
MineTweakerAPI.logCommand(str + ": " + BotaniaAPI.oreWeights.get(str) + "\n");
|
||||
}
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
package modtweaker.mods.forestry;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class ForestryHelper {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addCarpenterRecipeBox(ItemStack box) {
|
||||
Class clazz;
|
||||
try {
|
||||
clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager");
|
||||
Field field_box = clazz.getDeclaredField("list");
|
||||
field_box.setAccessible(true);
|
||||
|
||||
ArrayList<ItemStack> recipeFluids = (ArrayList<ItemStack>) field_box.get(clazz);
|
||||
recipeFluids.add(box);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addCarpenterRecipeFluids(Fluid newFluid) {
|
||||
Class clazz;
|
||||
@@ -14,7 +36,7 @@ public class ForestryHelper {
|
||||
clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager");
|
||||
Field field_recipeFluids = clazz.getDeclaredField("recipeFluids");
|
||||
field_recipeFluids.setAccessible(true);
|
||||
|
||||
|
||||
HashSet<Fluid> recipeFluids = (HashSet<Fluid>) field_recipeFluids.get(clazz);
|
||||
recipeFluids.add(newFluid);
|
||||
|
||||
|
||||
@@ -56,10 +56,20 @@ public class Carpenter {
|
||||
public Add(Recipe recipe) {
|
||||
super("Forestry Carpenter", MachineCarpenter.RecipeManager.recipes, recipe);
|
||||
|
||||
//The Carpenter has a list of valid Fluids, access them via Relfection because of private
|
||||
// The Carpenter has a list of valid Fluids, access them via
|
||||
// Relfection because of private
|
||||
if (recipe.getLiquid() != null)
|
||||
ForestryHelper.addCarpenterRecipeFluids(recipe.getLiquid().getFluid());
|
||||
|
||||
if(!RecipeManager.isBox(recipe.getBox())){
|
||||
ForestryHelper.addCarpenterRecipeBox(recipe.getBox());
|
||||
}
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
Recipe r = (MachineCarpenter.Recipe)recipe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
|
||||
Reference in new issue
Block a user