Commit 5b55d81b authored by Beeto's avatar Beeto

Re-integrate CraftTweaker support

Might need some work, might not. Hard to tell with the current
CurseForge build of CT.
parent 9892681e
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven { url = "http://files.minecraftforge.net/maven" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
version = "0.14.2-1.10.2"
group = "betterwithmods"
version = "1.0.0-1.11.2"
group = "betterwithmods" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Better With Mods"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
minecraft {
version = "1.11-13.19.0.2165"
version = "1.11.2-13.20.0.2226"
runDir = "run"
mappings = "snapshot_20161128"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20161220"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}
repositories {
maven {
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
maven {
name "Base"
url "http://blamejared.com/maven"
}
}
dependencies {
/*
deobfCompile "mezz.jei:jei_1.10.2:+"
deobfCompile "slimeknights.mantle:Mantle:1.10.2+"
deobfCompile "slimeknights:TConstruct:1.10.2+"
compile files('libs/')
*/
deobfCompile "mezz.jei:jei_1.11.2:+"
deobfCompile "MineTweaker3:MineTweaker3-API:+"
deobfCompile "com.blamejared:MTLib:+"
runtime "MineTweaker3:MineTweaker3-MC1112-Main:+"
}
jar {
......@@ -63,12 +73,12 @@ processResources {
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
......
......@@ -46,7 +46,7 @@ import java.util.*;
@Mod(modid = BWMod.MODID, name = BWMod.NAME, version = BWMod.VERSION, dependencies = "before:survivalist;after:tconstruct;after:minechem;after:natura;after:terrafirmacraft;after:immersiveengineering", guiFactory = "betterwithmods.client.gui.BWGuiFactory")
public class BWMod {
public static final String MODID = "betterwithmods";
public static final String VERSION = "1.0-RC6";
public static final String VERSION = "1.0.0";
public static final String NAME = "Better With Mods";
private static final Set<ICompatModule> loadedModules = new HashSet<>();
......@@ -70,7 +70,7 @@ public class BWMod {
map.put("biomesoplenty", "betterwithmods.integration.BiomesOPlenty");
map.put("harvestcraft", "betterwithmods.integration.Harvestcraft");
//map.put("immersiveengineering", "betterwithmods.integration.immersiveengineering.ImmersiveEngineering");
//map.put("MineTweaker3", "betterwithmods.integration.minetweaker.MineTweaker");
map.put("crafttweaker", "betterwithmods.integration.minetweaker.MineTweaker");
map.put("Quark", "betterwithmods.integration.Quark");
//map.put("tconstruct", "betterwithmods.integration.tcon.TConstruct");
map.put("nethercore", "betterwithmods.integration.NetherCore");
......
......@@ -6,10 +6,7 @@ import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.*;
/**
* Purpose:
......@@ -77,4 +74,18 @@ public abstract class BlockMetaHandler {
return null;
}
public List<BlockMetaRecipe> removeRecipes(ItemStack input) {
List<BlockMetaRecipe> removed = Lists.newArrayList();
Iterator<BlockMetaRecipe> it = recipes.iterator();
while(it.hasNext())
{
BlockMetaRecipe ir = it.next();
if(ir.getStack().isItemEqual(input))
{
removed.add(ir);
}
}
return removed;
}
}
......@@ -2,12 +2,14 @@ package betterwithmods.craft.bulk;
import betterwithmods.craft.OreStack;
import betterwithmods.util.InvUtils;
import com.google.common.collect.Lists;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public abstract class CraftingManagerBulk {
......@@ -57,6 +59,20 @@ public abstract class CraftingManagerBulk {
this.recipes.add(recipe);
}
public List<BulkRecipe> removeRecipes(ItemStack output) {
List<BulkRecipe> removed = Lists.newArrayList();
Iterator<BulkRecipe> it = recipes.iterator();
while(it.hasNext())
{
BulkRecipe ir = it.next();
if(ir.getOutput().isItemEqual(output))
{
removed.add(ir);
}
}
return removed;
}
public boolean removeRecipe(ItemStack output, Object[] inputs) {
return removeRecipe(output, null, inputs);
}
......
package betterwithmods.craft.steelanvil;
import com.google.common.collect.Lists;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
......@@ -9,6 +10,7 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
......@@ -30,15 +32,18 @@ public class CraftingManagerSteelAnvil {
return recipe;
}
public void removeRecipe(ItemStack result) {
List<IRecipe> toRemove = new ArrayList<>();
for (IRecipe recipe : this.recipes) {
if (OreDictionary.itemMatches(recipe.getRecipeOutput(), result, true)) {
toRemove.add(recipe);
public List<IRecipe> removeRecipes(ItemStack result) {
List<IRecipe> removed = Lists.newArrayList();
Iterator<IRecipe> it = recipes.iterator();
while(it.hasNext())
{
IRecipe ir = it.next();
if(OreDictionary.itemMatches(ir.getRecipeOutput(), result, true))
{
removed.add(ir);
}
}
for (IRecipe recipe : toRemove)
this.recipes.remove(recipe);
return removed;
}
public ItemStack findMatchingRecipe(InventoryCrafting matrix, World world) {
......
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.BlockMetaHandler;
import betterwithmods.craft.BlockMetaRecipe;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.google.common.collect.Lists;
/**
* Purpose:
*
* @author Tyler Marshall
* @version 1/2/17
*/
public class BMAdd extends BaseListAddition<BlockMetaRecipe> {
public BMAdd(String name, BlockMetaHandler recipes, BlockMetaRecipe recipe) {
super(name, recipes.getRecipes(), Lists.newArrayList(recipe));
}
@Override
protected String getRecipeInfo(BlockMetaRecipe recipe) {
return recipe.getStack().getDisplayName();
}
}
\ No newline at end of file
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.BlockMetaHandler;
import betterwithmods.craft.BlockMetaRecipe;
import com.blamejared.mtlib.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
/**
* Purpose:
*
* @author Tyler Marshall
* @version 1/2/17
*/
public class BMRemove extends BaseListRemoval<BlockMetaRecipe> {
protected BMRemove(String name, BlockMetaHandler recipes, ItemStack output) {
super(name, recipes.getRecipes(), recipes.removeRecipes(output));
}
@Override
protected String getRecipeInfo(BlockMetaRecipe recipe) {
return recipe.getStack().getDisplayName();
}
}
\ No newline at end of file
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.bulk.BulkRecipe;
import betterwithmods.craft.bulk.CraftingManagerBulk;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.google.common.collect.Lists;
/**
* Purpose:
*
* @author Tyler Marshall
* @version 1/2/17
*/
public class BulkAdd extends BaseListAddition<BulkRecipe> {
public BulkAdd(String name, CraftingManagerBulk recipes, BulkRecipe recipe) {
super(name, recipes.getRecipes(), Lists.newArrayList(recipe));
}
@Override
protected String getRecipeInfo(BulkRecipe recipe) {
return recipe.getOutput().getDisplayName();
}
}
\ No newline at end of file
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.bulk.BulkRecipe;
import betterwithmods.craft.bulk.CraftingManagerBulk;
import com.blamejared.mtlib.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
/**
* Purpose:
*
* @author Tyler Marshall
* @version 1/2/17
*/
public class BulkRemove extends BaseListRemoval<BulkRecipe> {
protected BulkRemove(String name, CraftingManagerBulk recipes, ItemStack output) {
super(name, recipes.getRecipes(), recipes.removeRecipes(output));
}
@Override
protected String getRecipeInfo(BulkRecipe recipe) {
return recipe.getOutput().getDisplayName();
}
}
\ No newline at end of file
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.bulk.BulkRecipe;
import betterwithmods.craft.bulk.CraftingManagerCauldron;
import betterwithmods.integration.minetweaker.utils.BaseListAddition;
import betterwithmods.integration.minetweaker.utils.BaseListRemoval;
import betterwithmods.integration.minetweaker.utils.LogHelper;
import betterwithmods.integration.minetweaker.utils.StackHelper;
import com.blamejared.mtlib.helpers.InputHelper;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.NotNull;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.ArrayList;
import java.util.List;
import static betterwithmods.integration.minetweaker.utils.InputHelper.*;
/**
* Created by tyler on 9/3/16.
* Purpose:
*
* @author Tyler Marshall
* @version 12/31/16
*/
@ZenClass("mods.betterwithmods.Cauldron")
@ZenClass(Cauldron.clazz)
public class Cauldron {
private final static List<BulkRecipe> recipes = CraftingManagerCauldron.getInstance().getRecipes();
public static final String clazz = "mods.betterwithmods.Cauldron";
@ZenMethod
public static void add(IItemStack output, IItemStack secondary, IIngredient[] inputs) {
MineTweakerAPI.apply(new Add(toStack(output), toStack(secondary), toInputs(inputs)));
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
BulkRecipe r = new BulkRecipe("cauldron", InputHelper.toStack(output), InputHelper.toStack(secondaryOutput),InputHelper.toObjects(inputs));
MineTweakerAPI.apply(new BulkAdd("cauldron", CraftingManagerCauldron.getInstance(),r));
}
@ZenMethod
public static void remove(IItemStack output) {
List<BulkRecipe> toRemove = new ArrayList<>();
for (BulkRecipe recipe : recipes) {
if (StackHelper.matches(output, toIItemStack(recipe.getOutput()))) {
toRemove.add(recipe);
}
}
if (!toRemove.isEmpty()) {
MineTweakerAPI.apply(new Remove(toRemove));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", "cauldron", output.toString()));
}
MineTweakerAPI.apply(new BulkRemove("cauldron", CraftingManagerCauldron.getInstance(),InputHelper.toStack(output)));
}
public static class Add extends BaseListAddition<BulkRecipe> {
protected Add(ItemStack output, ItemStack secondary, Object[] inputs) {
super("cauldron", Cauldron.recipes);
recipes.add(new BulkRecipe(this.name, output, secondary, inputs));
}
@Override
protected String getRecipeInfo(BulkRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
public static class Remove extends BaseListRemoval<BulkRecipe> {
protected Remove(List<BulkRecipe> list) {
super("cauldron", Cauldron.recipes, list);
}
@Override
protected String getRecipeInfo(BulkRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.ChoppingRecipe;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.Arrays;
@ZenClass(ChopRecipe.clazz)
public class ChopRecipe {
public static final String clazz = "mods.betterwithmods.ChopRecipe";
@ZenMethod
public static void add(IItemStack output, @Optional IItemStack bark, @Optional IItemStack sawdust, IItemStack log) {
ChoppingRecipe recipe = new ChoppingRecipe(InputHelper.toStack(output), InputHelper.toStack(bark), InputHelper.toStack(sawdust), InputHelper.toStack(log));
MineTweakerAPI.apply(new Add(recipe));
}
public static class Add extends BaseListAddition<IRecipe> {
public Add(IRecipe recipe) {
super("chopping", CraftingManager.getInstance().getRecipeList(), Arrays.asList(recipe));
}
@Override
protected String getRecipeInfo(IRecipe recipe) {
return recipe.getRecipeOutput().getDisplayName();
}
}
}
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.bulk.BulkRecipe;
import betterwithmods.craft.bulk.CraftingManagerCrucible;
import betterwithmods.integration.minetweaker.utils.BaseListAddition;
import betterwithmods.integration.minetweaker.utils.BaseListRemoval;
import betterwithmods.integration.minetweaker.utils.LogHelper;
import betterwithmods.integration.minetweaker.utils.StackHelper;
import com.blamejared.mtlib.helpers.InputHelper;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.NotNull;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.ArrayList;
import java.util.List;
import static betterwithmods.integration.minetweaker.utils.InputHelper.*;
/**
* Created by tyler on 9/3/16.
* Purpose:
*
* @author Tyler Marshall
* @version 12/31/16
*/
@ZenClass("mods.betterwithmods.Crucible")
@ZenClass(Crucible.clazz)
public class Crucible {
private final static List<BulkRecipe> recipes = CraftingManagerCrucible.getInstance().getRecipes();
public static final String clazz = "mods.betterwithmods.Crucible";
@ZenMethod
public static void add(IItemStack output, IItemStack secondary, IIngredient[] inputs) {
MineTweakerAPI.apply(new Add(toStack(output), toStack(secondary), toInputs(inputs)));
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
BulkRecipe r = new BulkRecipe("crucible", InputHelper.toStack(output), InputHelper.toStack(secondaryOutput), InputHelper.toObjects(inputs));
MineTweakerAPI.apply(new BulkAdd("crucible", CraftingManagerCrucible.getInstance(), r));
}
@ZenMethod
public static void remove(IItemStack output) {
List<BulkRecipe> toRemove = new ArrayList<>();
for (BulkRecipe recipe : recipes) {
if (StackHelper.matches(output, toIItemStack(recipe.getOutput()))) {
toRemove.add(recipe);
}
}
if (!toRemove.isEmpty()) {
MineTweakerAPI.apply(new Remove(toRemove));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", "crucible", output.toString()));
}
}
public static class Add extends BaseListAddition<BulkRecipe> {
protected Add(ItemStack output, ItemStack secondary, Object[] inputs) {
super("crucible", Crucible.recipes);
recipes.add(new BulkRecipe(this.name, output, secondary, inputs));
}
@Override
protected String getRecipeInfo(BulkRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
MineTweakerAPI.apply(new BulkRemove("crucible", CraftingManagerCrucible.getInstance(), InputHelper.toStack(output)));
}
public static class Remove extends BaseListRemoval<BulkRecipe> {
protected Remove(List<BulkRecipe> list) {
super("crucible", Crucible.recipes, list);
}
@Override
protected String getRecipeInfo(BulkRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
package betterwithmods.integration.minetweaker;
import betterwithmods.craft.BlockMetaRecipe;
import betterwithmods.craft.KilnInteraction;
import betterwithmods.integration.minetweaker.utils.BaseListAddition;
import betterwithmods.integration.minetweaker.utils.LogHelper;
import com.blamejared.mtlib.helpers.InputHelper;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.NotNull;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static betterwithmods.integration.minetweaker.utils.InputHelper.*;
import static betterwithmods.integration.minetweaker.utils.StackHelper.matches;
/**
* Created by tyler on 9/3/16.
* Purpose:
*
* @author Tyler Marshall
* @version 12/31/16
*/
@ZenClass("mods.betterwithmods.Kiln")
@ZenClass(Kiln.clazz)
public class Kiln {
private static final ArrayList<BlockMetaRecipe> recipes = KilnInteraction.INSTANCE.getRecipes();
@ZenMethod
public static void add(IItemStack input, IItemStack[] output) {
ItemStack stack = toStack(input);
Block block = Block.getBlockFromItem(stack.getItem());
MineTweakerAPI.apply(new Add(block, stack.getMetadata(), toStacks(output)));
}
public static final String clazz = "mods.betterwithmods.Kiln";
@ZenMethod
public static void remove(IIngredient output) {
ArrayList<BlockMetaRecipe> toRemove = new ArrayList<>();
for (BlockMetaRecipe recipe : recipes) {
if (recipe != null && matches(output, toIItemStack(recipe.getOutputs().get(0)))) {
toRemove.add(recipe);
}
}
if (!toRemove.isEmpty()) {
MineTweakerAPI.apply(new Remove(toRemove));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", "kiln", output.toString()));
public static void add(IItemStack[] output, @NotNull IItemStack input) {
ItemStack blockMeta = InputHelper.toStack(input);
if(!InputHelper.isABlock(blockMeta))
MineTweakerAPI.getLogger().logError(input.getDisplayName() + " is not a Block");
Block block = ((ItemBlock)blockMeta.getItem()).getBlock();
ItemStack[] outputs = InputHelper.toStacks(output);
if (output == null) {
MineTweakerAPI.getLogger().logError("Could not add " + clazz + " recipe for " + input.getDisplayName() + ", outputs were null");
}
BlockMetaRecipe r = new BlockMetaRecipe("kiln", block, blockMeta.getMetadata(), Arrays.asList(outputs));
MineTweakerAPI.apply(new BMAdd("kiln", KilnInteraction.INSTANCE,r));
}
private static class Add extends BaseListAddition<BlockMetaRecipe> {
protected Add(Block block, int meta, ItemStack... product) {
super("kiln", Kiln.recipes);
recipes.add(new BlockMetaRecipe(block, meta, Arrays.asList(product)));
}
@Override
protected String getRecipeInfo(BlockMetaRecipe recipe) {
return recipe.toString();
}
@ZenMethod
public static void remove(IItemStack output) {
MineTweakerAPI.apply(new BMRemove("kiln", KilnInteraction.INSTANCE,InputHelper.toStack(output)));
}
private static class Remove extends BaseListAddition<BlockMetaRecipe> {
protected Remove(List<BlockMetaRecipe> list) {
super("kiln", Kiln.recipes, list);
}
@Override
protected String getRecipeInfo(BlockMetaRecipe recipe) {
return recipe.toString();
}
}
}
......@@ -2,71 +2,36 @@ package betterwithmods.integration.minetweaker;
import betterwithmods.craft.bulk.BulkRecipe;
import betterwithmods.craft.bulk.CraftingManagerMill;
import betterwithmods.integration.minetweaker.utils.BaseListAddition;
import betterwithmods.integration.minetweaker.utils.BaseListRemoval;
import betterwithmods.integration.minetweaker.utils.LogHelper;
import betterwithmods.integration.minetweaker.utils.StackHelper;
import com.blamejared.mtlib.helpers.InputHelper;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.NotNull;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.ArrayList;
import java.util.List;
import static betterwithmods.integration.minetweaker.utils.InputHelper.*;
/**
* Created by tyler on 9/3/16.
* Purpose:
*
* @author Tyler Marshall
* @version 12/31/16
*/
@ZenClass("mods.betterwithmods.Mill")
@ZenClass(Mill.clazz)
public class Mill {
private final static List<BulkRecipe> recipes = CraftingManagerMill.getInstance().getRecipes();
public static final String clazz = "mods.betterwithmods.Mill";
@ZenMethod
public static void add(IItemStack output, IItemStack secondary, IIngredient[] inputs) {
MineTweakerAPI.apply(new Add(toStack(output), toStack(secondary), toInputs(inputs)));
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
BulkRecipe r = new BulkRecipe("mill", InputHelper.toStack(output),InputHelper.toStack(secondaryOutput),InputHelper.toObjects(inputs));
MineTweakerAPI.apply(new BulkAdd("mill", CraftingManagerMill.getInstance(),r));
}
@ZenMethod
public static void remove(IItemStack output) {
List<BulkRecipe> toRemove = new ArrayList<>();
for (BulkRecipe recipe : recipes) {
if (StackHelper.matches(output, toIItemStack(recipe.getOutput()))) {
toRemove.add(recipe);
}
}