Skip to content

Commit

Permalink
Moved output of recipe file to scripts to avoid issues. The old fil…
Browse files Browse the repository at this point in the history
…e gets moved over automagically.
  • Loading branch information
dries007 committed Oct 17, 2016
1 parent 11596a1 commit cc54c65
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
sourceCompatibility = 1.8
targetCompatibility = 1.8

version = "1.2.0"
version = "1.2.1"
if (System.getenv().BUILD_NUMBER != null) version += "." + System.getenv().BUILD_NUMBER

group = "net.doubledoordev.mtrm"
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/doubledoordev/mtrm/MTRMCommand.java
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;

import java.util.Arrays;
Expand Down
Expand Up @@ -10,6 +10,7 @@
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import org.apache.logging.log4j.Logger;

import java.util.Map;

Expand All @@ -26,6 +27,12 @@ public class MineTweakerRecipeMaker
public static MineTweakerRecipeMaker instance;

private SimpleNetworkWrapper snw;
private Logger logger;

public static Logger getLogger()
{
return instance.logger;
}

public static SimpleNetworkWrapper getSnw()
{
Expand All @@ -35,6 +42,8 @@ public static SimpleNetworkWrapper getSnw()
@Mod.EventHandler
public void init(FMLPreInitializationEvent event)
{
logger = event.getModLog();

NetworkRegistry.INSTANCE.registerGuiHandler(this, new MTRMGuiHandler());

int id = 0;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/doubledoordev/mtrm/gui/MTRMGui.java
Expand Up @@ -14,8 +14,6 @@
import net.minecraftforge.fml.client.config.GuiButtonExt;
import net.minecraftforge.fml.client.config.GuiCheckBox;
import net.minecraftforge.fml.client.config.GuiSlider;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.opengl.GL11;

Expand Down Expand Up @@ -127,7 +125,7 @@ public String getStackToken(boolean nextOreDict, ItemStack stack)
boolean metaWildcard = this.metaWildcard.isChecked();
boolean oreDict = this.oreDict.isChecked();
if (stack == null) return "null";
String stackName = GameData.getItemRegistry().getNameForObject(stack.getItem()).toString();
String stackName = stack.getItem().getRegistryName().toString();
StringBuilder builder = new StringBuilder("<");
if (oreDict)
{
Expand Down Expand Up @@ -160,7 +158,7 @@ public String getStackToken(boolean nextOreDict, ItemStack stack)
if (giveBack.isChecked()) builder.append(".giveBack(<");
else if (transformReplace.isChecked()) builder.append(".transformReplace(<");

builder.append(GameData.getItemRegistry().getNameForObject(returnStack.getItem()));
builder.append(returnStack.getItem().getRegistryName());
if (returnStack.getItemDamage() != 0) builder.append(':').append(returnStack.getItemDamage());
builder.append('>');
if (returnStack.stackSize > 1) builder.append(" * ").append(returnStack.stackSize);
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/net/doubledoordev/mtrm/network/MessageSend.java
@@ -1,6 +1,7 @@
package net.doubledoordev.mtrm.network;

import io.netty.buffer.ByteBuf;
import net.doubledoordev.mtrm.MineTweakerRecipeMaker;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
Expand All @@ -10,7 +11,6 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
Expand Down Expand Up @@ -127,8 +127,17 @@ private MessageResponse makeScript()
}
if (data[0] == null) return new MessageResponse(MessageResponse.Status.NO_OUT);
if (!remove && noIngredients) return new MessageResponse(MessageResponse.Status.NO_IN);
File file = new File("scripts/MineTweakerRecipeMaker/scripts/", "Crafting.zs");
File oldFile = new File("scripts/MineTweakerRecipeMaker/scripts/", "Crafting.zs");
File file = new File("scripts", MineTweakerRecipeMaker.NAME + ".zs");
if (!file.getParentFile().exists()) file.getParentFile().mkdirs();
try
{
if (oldFile.exists()) FileUtils.moveFile(oldFile, file);
}
catch (IOException e)
{
e.printStackTrace();
}
if (!file.exists())
{
try
Expand Down Expand Up @@ -192,9 +201,9 @@ private MessageResponse makeScript()
{
Class.forName("minetweaker.MineTweakerImplementationAPI").getDeclaredMethod("reload").invoke(null);
}
catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored)
catch (Exception e)
{

MineTweakerRecipeMaker.getLogger().info("Auto reload failed. Nothing to be worried about, just annoying.", e);
}
}
catch (IOException e)
Expand Down

0 comments on commit cc54c65

Please sign in to comment.