Merge remote-tracking branch 'refs/remotes/origin/master'

Conflicts:
	src/main/java/modtweaker/ModTweaker.java
This commit is contained in:
Jared 2016-12-01 03:45:07 +02:00
commit cf613c6a34
5 changed files with 207 additions and 52 deletions

View file

@ -41,10 +41,20 @@ repositories {
name 'Jared'
url 'http://blamejared.com/maven'
}
maven {
name = 'raoulvdberge'
url 'https://dl.bintray.com/raoulvdberge/dev/'
}
maven {
name = 'amadornes'
url "http://maven.amadornes.com/"
}
}
dependencies {
deobfCompile "com.blamejared:MTLib:1.0.0.6"
deobfCompile "refinedstorage:refinedstorage:1.2.5-559"
deobfCompile "MCMultiPart:MCMultiPart:1.3.0:universal"
}
processResources

View file

@ -1,3 +1,3 @@
minecraft.version=1.10.2
forge.version=1.10.2-12.18.2.2107
forge.version=1.10.2-12.18.2.2116
mod.version=2.0.6

View file

@ -10,6 +10,7 @@ import modtweaker.mods.chisel.Chisel;
import modtweaker.mods.extrautils.ExtraUtilities;
import modtweaker.mods.forestry.Forestry;
import modtweaker.mods.randomthings.RandomThings;
import modtweaker.mods.refinedstorage.RefinedStorage;
import modtweaker.mods.tconstruct.TConstruct;
import modtweaker.proxy.CommonProxy;
import net.minecraftforge.common.MinecraftForge;
@ -24,55 +25,54 @@ import java.util.Arrays;
@Mod(modid = ModProps.modid, version = ModProps.version, dependencies = ModProps.dependencies)
public class ModTweaker {
public static Logger logger = LogManager.getLogger(ModProps.modid);
@SidedProxy(clientSide = "modtweaker.proxy.ClientProxy", serverSide = "modtweaker.proxy.CommonProxy")
public static CommonProxy proxy;
@Instance(ModProps.modid)
public ModTweaker instance;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
logger.info("Starting PreInitialization for " + ModProps.modid);
GuiRegistry.registerGui(Arrays.asList(3), new GuiHandlerMods());
}
@EventHandler
public void init(FMLInitializationEvent event) {
logger.info("Starting Initialization for " + ModProps.modid);
TweakerPlugin.register("forestry", Forestry.class);
TweakerPlugin.register("tconstruct", TConstruct.class);
TweakerPlugin.register("randomthings", RandomThings.class);
TweakerPlugin.register("Botania", Botania.class);
TweakerPlugin.register("chisel", Chisel.class);
TweakerPlugin.register("BloodMagic", BloodMagic.class);
TweakerPlugin.register("actuallyadditions", ActuallyAdditions.class);
TweakerPlugin.register("ExtraUtils2", ExtraUtilities.class);
if(FMLCommonHandler.instance().getSide() == Side.CLIENT) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());
}
MineTweakerImplementationAPI.onReloadEvent(event1 -> proxy.registerCommands());
File scripts = new File("scripts");
if(!scripts.exists()) {
scripts.mkdir();
}
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderDirectory(scripts));
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
logger.info("Starting PostInitialization for " + ModProps.modid);
}
@EventHandler
public void serverStart(FMLServerStartingEvent event) {
logger.info("Starting ServerStart for " + ModProps.modid);
proxy.registerCommands();
}
public static Logger logger = LogManager.getLogger(ModProps.modid);
@SidedProxy(clientSide = "modtweaker.proxy.ClientProxy", serverSide = "modtweaker.proxy.CommonProxy")
public static CommonProxy proxy;
@Instance(ModProps.modid)
public ModTweaker instance;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
logger.info("Starting PreInitialization for " + ModProps.modid);
GuiRegistry.registerGui(Arrays.asList(3), new GuiHandlerMods());
}
@EventHandler
public void init(FMLInitializationEvent event) {
logger.info("Starting Initialization for " + ModProps.modid);
TweakerPlugin.register("forestry", Forestry.class);
TweakerPlugin.register("tconstruct", TConstruct.class);
TweakerPlugin.register("randomthings", RandomThings.class);
TweakerPlugin.register("Botania", Botania.class);
TweakerPlugin.register("chisel", Chisel.class);
TweakerPlugin.register("BloodMagic", BloodMagic.class);
TweakerPlugin.register("actuallyadditions", ActuallyAdditions.class);
TweakerPlugin.register("refinedstorage", RefinedStorage.class);
if(FMLCommonHandler.instance().getSide() == Side.CLIENT) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());
}
MineTweakerImplementationAPI.onReloadEvent(event1 -> proxy.registerCommands());
File scripts = new File("scripts");
if(!scripts.exists()) {
scripts.mkdir();
}
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderDirectory(scripts));
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
logger.info("Starting PostInitialization for " + ModProps.modid);
}
@EventHandler
public void serverStart(FMLServerStartingEvent event) {
logger.info("Starting ServerStart for " + ModProps.modid);
proxy.registerCommands();
}
}

View file

@ -0,0 +1,11 @@
package modtweaker.mods.refinedstorage;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.refinedstorage.handlers.Solderer;
public class RefinedStorage {
public RefinedStorage() {
MineTweakerAPI.registerClass(Solderer.class);
}
}

View file

@ -0,0 +1,134 @@
package modtweaker.mods.refinedstorage.handlers;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
@ZenClass("mods.refinedstorage.Solderer")
public class Solderer {
@ZenMethod
public static void add(IItemStack output, int time, IItemStack row2) {
add(output, time, null, row2, null);
}
@ZenMethod
public static void add(IItemStack output, int time, IItemStack row1, IItemStack row2, @Optional IItemStack row3) {
MineTweakerAPI.apply(new Add(createISoldererRecipe(InputHelper.toStack(output), time, InputHelper.toStack(row1), InputHelper.toStack(row2), InputHelper.toStack(row3))));
}
@ZenMethod
public static void remove(IItemStack output) {
MineTweakerAPI.apply(new Remove(new SoldererRemovalRecipe(InputHelper.toStack(output))));
}
private static ISoldererRecipe createISoldererRecipe(ItemStack output, int time, ItemStack... rows) {
return API.instance().getSoldererRegistry().createSimpleRecipe(output, time, rows);
}
private static class Add extends BaseListAddition<ISoldererRecipe> {
protected Add(ISoldererRecipe recipe) {
super("Solderer", API.instance().getSoldererRegistry().getRecipes());
this.recipes.add(recipe);
}
@Override
protected String getRecipeInfo(ISoldererRecipe recipe) {
StringBuilder build = new StringBuilder();
build.append("ISoldererRecipe");
build.append(LogHelper.getStackDescription(recipe.getResult())).append("; ");
build.append("duration:").append(recipe.getDuration()).append("; ");
for (int i = 0; i < 3; i++) {
build.append(LogHelper.getStackDescription(recipe.getRow(i))).append(", ");
}
build.setLength(build.length() - 2);
return build.toString();
}
@Override
public void undo() {
for (ISoldererRecipe recipe : this.successful) {
if (recipe != null) {
if (API.instance().getSoldererRegistry().removeRecipe(recipe.getResult(), recipe.getRow(0), recipe.getRow(1), recipe.getRow(2)).size() > 0) {
} else {
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe)));
}
} else {
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
}
}
}
}
private static class Remove extends BaseListRemoval<ISoldererRecipe> {
protected Remove(ISoldererRecipe recipe) {
super("Solderer", API.instance().getSoldererRegistry().getRecipes());
this.recipes.add(recipe);
}
@Override
public void apply() {
if (recipes.isEmpty()) {
return;
}
for (ISoldererRecipe recipe : this.recipes) {
if (recipe != null) {
List<ISoldererRecipe> removed = API.instance().getSoldererRegistry().removeRecipe(recipe.getResult());
if (removed.size() > 0) {
successful.addAll(removed);
} else {
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe)));
}
} else {
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
}
}
}
@Override
protected String getRecipeInfo(ISoldererRecipe recipe) {
return "SoldererRemovalRecipe:" + LogHelper.getStackDescription(recipe.getResult());
}
}
private static class SoldererRemovalRecipe implements ISoldererRecipe {
private ItemStack output;
protected SoldererRemovalRecipe(ItemStack output) {
this.output = output;
}
@Nullable
@Override
public ItemStack getRow(int i) {
return null;
}
@Nonnull
@Override
public ItemStack getResult() {
return this.output;
}
@Override
public int getDuration() {
return 0;
}
}
}