Compare commits

...
21 Commits
Author SHA1 Message Date
DreamMasterXXL 5044de32dd bump version 2021-10-18 22:33:21 +02:00
Martin Robertz 7b75ffb679 Merge pull request #6 from GTNewHorizons/patch-sorted-scripts
Sort received scripts in alphabetic order to prevent weird recipe loss
2021-10-18 20:38:20 +02:00
Glease 4787672b6e Sort received scripts according to their names 2021-10-19 02:36:12 +08:00
Martin Robertz 22502ff016 Merge pull request #5 from repo-alt/gtnh-legacy
restored ZenScript submodule pointer
2021-08-02 19:22:16 +02:00
repo_alt 7c060cb624 restored ZenScript submodule pointer 2021-08-02 20:20:21 +03:00
Martin Robertz b6a27cb150 Merge pull request #4 from repo-alt/gtnh-legacy
updated ZenScript submodule
2021-08-02 18:58:33 +02:00
repo_alt 6ffcca483f updated ZenScript submodule 2021-08-02 19:55:21 +03:00
DreamMasterXXL dc78b2b39e Merge remote-tracking branch 'origin/legacy' into gtnh-legacy
# Conflicts:
#	gradle/wrapper/gradle-wrapper.properties
2021-08-02 18:21:35 +02:00
Martin Robertz 436ad039ca Merge pull request #3 from Zaxar163/fix-legacy
Add more configuration options to MineTweaker network + update gradle.
2021-08-02 18:14:41 +02:00
Zaxar163 a348865dda Remove usage of sun.* in MineTweakerImplementationAPI 2021-06-29 10:25:16 +03:00
Zaxar163 86b4108e4f Configuration!
Config options:
handleDesktopPackets (Handle OpenBrowser and CopyClipboard packets? Insecure. Default false),
handleLoadScripts (Proccess LoadScripts packet on client? Insecure, takes time, but update scripts on the fly... Default true),
sendLoadScripts (Send scripts to players on logging in. Default true),
sendScriptsOnReloading (Send scripts to players on command "mt reload". Default true),
loadScriptsOnConnection (Load scripts before connect to server? Save time and traffic. Requires server with disabled sendLoadScripts. Default false),
antiStuck (Do not reload scripts when relogging, saves time. Usable when playing on one server/singleplayer... Default false).
Config lies at config/MineTweaker3.cfg
2021-06-29 10:24:43 +03:00
Zaxar163 4d4fed2482 Update gradle. 2021-06-29 10:24:32 +03:00
DreamMasterXXL 1796484e7c add(Craft-Tweaker)Changelog
update gradle
2021-06-28 10:12:45 +02:00
Jason Mitchell 8fff244d95 Make things undoable -- should (mostly) fix /mt reload 2020-11-29 16:37:29 -08:00
bartimaeusnek e4a0cc8f35 Fixed an oversight 2020-11-29 21:13:49 +01:00
bartimaeusnek 7c0eb67215 This is why i should init submodules. 2020-11-29 21:10:20 +01:00
bartimaeusnek 9167cd1f1d Added Overloads 2020-11-29 21:04:11 +01:00
Jason Mitchell 11c68ce42a Bump version 2020-11-29 11:32:22 -08:00
Jason Mitchell 94705aeacf Revert API Changes 2020-11-29 11:31:33 -08:00
Jason Mitchell af79e56481 Merge pull request #2 from GTNewHorizons/gtnh-legacy
Speedup - Inspired by the 1.12 version
2020-11-15 19:04:32 -08:00
Jason Mitchell 449ce974f4 Speedup - Inspired by the 1.12 version 2020-11-15 15:05:25 -08:00
31 changed files with 773 additions and 479 deletions

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
# CraftTweaker
Changelog of CraftTweaker.
+3 -4
View File
@@ -7,12 +7,11 @@ version = ext.mineTweakerVersion
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = 1.8
targetCompatibility = 1.8
task makeRegistry(type: RegisterZenClassesTask) { task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main') dependsOn tasks.compileJava
outputDir = file('build/classes/main') inputDir = file('build/classes/java/main')
outputDir = file('build/classes/java/main')
className = 'minetweaker.ClassRegistry' className = 'minetweaker.ClassRegistry'
} }
@@ -27,7 +27,6 @@ import minetweaker.api.world.IBiome;
import minetweaker.runtime.IScriptProvider; import minetweaker.runtime.IScriptProvider;
import minetweaker.util.EventList; import minetweaker.util.EventList;
import minetweaker.util.IEventHandler; import minetweaker.util.IEventHandler;
import sun.awt.HeadlessToolkit;
import java.awt.*; import java.awt.*;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
@@ -58,8 +57,9 @@ public class MineTweakerImplementationAPI {
private static final ListenPlayerLoggedIn LISTEN_LOGIN = new ListenPlayerLoggedIn(); private static final ListenPlayerLoggedIn LISTEN_LOGIN = new ListenPlayerLoggedIn();
private static final ListenPlayerLoggedOut LISTEN_LOGOUT = new ListenPlayerLoggedOut(); private static final ListenPlayerLoggedOut LISTEN_LOGOUT = new ListenPlayerLoggedOut();
private static final ListenBlockInfo LISTEN_BLOCK_INFO = new ListenBlockInfo(); private static final ListenBlockInfo LISTEN_BLOCK_INFO = new ListenBlockInfo();
private static final EventList<ReloadEvent> ONRELOAD = new EventList<ReloadEvent>(); private static final EventList<ReloadEvent> ONROLLBACK = new EventList<>();
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<ReloadEvent>(); private static final EventList<ReloadEvent> ONRELOAD = new EventList<>();
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<>();
static { static {
minetweakerCommands = new HashMap<String, MineTweakerCommand>(); minetweakerCommands = new HashMap<String, MineTweakerCommand>();
@@ -573,6 +573,9 @@ public class MineTweakerImplementationAPI {
* @param handler * @param handler
* @return * @return
*/ */
public static IEventHandle onRollbackEvent(IEventHandler<ReloadEvent> handler) {
return ONROLLBACK.add(handler);
}
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) { public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
return ONRELOAD.add(handler); return ONRELOAD.add(handler);
} }
@@ -621,29 +624,10 @@ public class MineTweakerImplementationAPI {
events.onPlayerLoggedIn(LISTEN_LOGIN); events.onPlayerLoggedIn(LISTEN_LOGIN);
events.onPlayerLoggedOut(LISTEN_LOGOUT); events.onPlayerLoggedOut(LISTEN_LOGOUT);
} }
//
// byte[] currentScript = MineTweakerAPI.tweaker.getScriptData();
// if (currentScript != null) {
// System.out.println("Already loaded a script before");
//
// // alread loaded a script
// byte[] stagedScript = MineTweakerAPI.tweaker.getStagedScriptData();
//
// if (Arrays.equals(currentScript, stagedScript)) {
// System.out.println("No reload needed");
// return; // no reload necessary
// }
//
// if (MineTweakerAPI.game.isLocked()) {
// System.out.println("Reload blocked");
// MineTweakerAPI.game.signalLockError();
// return;
// }
// } else {
// System.out.println("First time loading a script, go ahead");
// }
MineTweakerAPI.tweaker.rollback(); MineTweakerAPI.tweaker.rollback();
ONROLLBACK.publish(new ReloadEvent());
if (MineTweakerAPI.server != null) { if (MineTweakerAPI.server != null) {
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) { if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() { server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() {
@@ -707,7 +691,7 @@ public class MineTweakerImplementationAPI {
private static void copyToClipboard(String value) { private static void copyToClipboard(String value) {
StringSelection stringSelection = new StringSelection(value); StringSelection stringSelection = new StringSelection(value);
if (!(Toolkit.getDefaultToolkit() instanceof HeadlessToolkit)) { if (Desktop.isDesktopSupported()) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null); clipboard.setContents(stringSelection, null);
} }
@@ -41,7 +41,9 @@ public interface IRecipeManager {
*/ */
@ZenMethod @ZenMethod
int remove(IIngredient output, @Optional boolean nbtMatch); int remove(IIngredient output, @Optional boolean nbtMatch);
int remove(IIngredient output);
/** /**
* Adds a shaped recipe. * Adds a shaped recipe.
* *
@@ -51,7 +53,12 @@ public interface IRecipeManager {
*/ */
@ZenMethod @ZenMethod
void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action); void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
void addShaped(IItemStack output, IIngredient[][] ingredients);
/** /**
* Adds a mirrored shaped recipe. * Adds a mirrored shaped recipe.
* *
@@ -61,7 +68,12 @@ public interface IRecipeManager {
*/ */
@ZenMethod @ZenMethod
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action); void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients);
/** /**
* Adds a shapeless recipe. * Adds a shapeless recipe.
* *
@@ -71,7 +83,13 @@ public interface IRecipeManager {
*/ */
@ZenMethod @ZenMethod
void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action); void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function);
void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeAction action);
void addShapeless(IItemStack output, IIngredient[] ingredients);
/** /**
* Removes shaped recipes. * Removes shaped recipes.
* *
@@ -82,7 +100,8 @@ public interface IRecipeManager {
*/ */
@ZenMethod @ZenMethod
int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients); int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients);
int removeShaped(IIngredient output);
/** /**
* Removes shapeless recipes. * Removes shapeless recipes.
* *
@@ -95,7 +114,13 @@ public interface IRecipeManager {
*/ */
@ZenMethod @ZenMethod
int removeShapeless(IIngredient output, @Optional IIngredient[] ingredients, @Optional boolean wildcard); int removeShapeless(IIngredient output, @Optional IIngredient[] ingredients, @Optional boolean wildcard);
int removeShapeless(IIngredient output, boolean wildcard);
int removeShapeless(IIngredient output, IIngredient[] ingredients);
int removeShapeless(IIngredient output);
/** /**
* Performs a crafting with the specified ingredients. Returns null if no * Performs a crafting with the specified ingredients. Returns null if no
* crafting recipe exists. * crafting recipe exists.
@@ -28,21 +28,14 @@ public class ShapedRecipe implements ICraftingRecipe {
public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) { public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
int numIngredients = 0; int numIngredients = 0;
for(int i = 0; i < ingredients.length; i++) { for (IIngredient[] ingredient : ingredients) {
IIngredient[] ingredient = ingredients[i]; for (IIngredient iIngredient : ingredient) {
for(int i1 = 0; i1 < ingredient.length; i1++) { if (iIngredient != null) {
if(ingredient[i1] != null) {
numIngredients++; numIngredients++;
} }
} }
} }
// for(IIngredient[] row : ingredients) {
// for(IIngredient ingredient : row) {
// if(ingredient != null) {
// numIngredients++;
// }
// }
// }
this.posx = new byte[numIngredients]; this.posx = new byte[numIngredients];
this.posy = new byte[numIngredients]; this.posy = new byte[numIngredients];
this.output = output; this.output = output;
@@ -52,6 +52,7 @@ public class MTTweaker implements ITweaker {
Object overrideKey = action.getOverrideKey(); Object overrideKey = action.getOverrideKey();
if (wereStuck.contains(action)) { if (wereStuck.contains(action)) {
MineTweakerAPI.logInfo("WAS STUCK");
wereStuck.remove(action); wereStuck.remove(action);
if (overrideKey != null) { if (overrideKey != null) {
@@ -76,7 +77,8 @@ public class MTTweaker implements ITweaker {
@Override @Override
public List<IUndoableAction> rollback() { public List<IUndoableAction> rollback() {
List<IUndoableAction> stuck = new ArrayList<IUndoableAction>(); // Note: Requires a OnRollback event to be fired. If this is called from MineTweakerImplementationAPI it's handled there.
List<IUndoableAction> stuck = new ArrayList<>();
for (int i = actions.size() - 1; i >= 0; i--) { for (int i = actions.size() - 1; i >= 0; i--) {
IUndoableAction action = actions.get(i); IUndoableAction action = actions.get(i);
if (action.canUndo()) { if (action.canUndo()) {
@@ -111,7 +113,7 @@ public class MTTweaker implements ITweaker {
System.out.println("Loading scripts"); System.out.println("Loading scripts");
scriptData = ScriptProviderMemory.collect(scriptProvider); scriptData = ScriptProviderMemory.collect(scriptProvider);
Set<String> executed = new HashSet<String>(); Set<String> executed = new HashSet<>();
Iterator<IScriptIterator> scripts = scriptProvider.getScripts(); Iterator<IScriptIterator> scripts = scriptProvider.getScripts();
while (scripts.hasNext()) { while (scripts.hasNext()) {
@@ -120,10 +122,10 @@ public class MTTweaker implements ITweaker {
if (!executed.contains(script.getGroupName())) { if (!executed.contains(script.getGroupName())) {
executed.add(script.getGroupName()); executed.add(script.getGroupName());
Map<String, byte[]> classes = new HashMap<String, byte[]>(); Map<String, byte[]> classes = new HashMap<>();
IEnvironmentGlobal environmentGlobal = GlobalRegistry.makeGlobalEnvironment(classes); IEnvironmentGlobal environmentGlobal = GlobalRegistry.makeGlobalEnvironment(classes);
List<ZenParsedFile> files = new ArrayList<ZenParsedFile>(); List<ZenParsedFile> files = new ArrayList<>();
while (script.next()) { while (script.next()) {
Reader reader = null; Reader reader = null;
@@ -12,13 +12,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.DeflaterOutputStream; import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream; import java.util.zip.InflaterInputStream;
import minetweaker.MineTweakerAPI; import minetweaker.MineTweakerAPI;
@@ -74,7 +68,7 @@ public class ScriptProviderMemory implements IScriptProvider {
private final Map<String, MemoryModule> modules; private final Map<String, MemoryModule> modules;
public ScriptProviderMemory(byte[] scripts) { public ScriptProviderMemory(byte[] scripts) {
modules = new HashMap<String, MemoryModule>(); modules = new TreeMap<String, MemoryModule>();
try { try {
InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(scripts)); InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(scripts));
+3 -21
View File
@@ -1,29 +1,10 @@
import minetweaker.tasks.RegisterZenClassesTask; import minetweaker.tasks.RegisterZenClassesTask;
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
apply plugin: 'forge' apply plugin: 'forge'
apply plugin: 'maven' apply plugin: 'maven'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = "1.7.10-" + ext.mineTweakerVersion version = "1.7.10-" + ext.mineTweakerVersion
archivesBaseName = project.projectDir.name archivesBaseName = project.projectDir.name
@@ -40,8 +21,9 @@ dependencies {
} }
task makeRegistry(type: RegisterZenClassesTask) { task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main') dependsOn tasks.compileJava
outputDir = file('build/classes/main') inputDir = file('build/classes/java/main')
outputDir = file('build/classes/java/main')
className = 'minetweaker.mc1710.MineTweakerRegistry' className = 'minetweaker.mc1710.MineTweakerRegistry'
} }
@@ -10,6 +10,7 @@ import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer; import minetweaker.api.player.IPlayer;
import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket; import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket;
import minetweaker.mc1710.recipes.MCCraftingInventory; import minetweaker.mc1710.recipes.MCCraftingInventory;
import minetweaker.mc1710.recipes.MCRecipeManager;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.PlayerEvent;
@@ -21,7 +22,7 @@ import cpw.mods.fml.common.gameevent.PlayerEvent;
public class FMLEventHandler { public class FMLEventHandler {
@SubscribeEvent @SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) { public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) {
if (ev.player instanceof EntityPlayerMP) { if (ev.player instanceof EntityPlayerMP && MineTweakerConfig.sendLoadScripts) {
EntityPlayerMP player = (EntityPlayerMP) ev.player; EntityPlayerMP player = (EntityPlayerMP) ev.player;
MineTweakerMod.NETWORK.sendTo(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()), player); MineTweakerMod.NETWORK.sendTo(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()), player);
} }
@@ -32,8 +33,8 @@ public class FMLEventHandler {
@SubscribeEvent @SubscribeEvent
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent ev) { public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent ev) {
IPlayer iPlayer = MineTweakerMC.getIPlayer(ev.player); IPlayer iPlayer = MineTweakerMC.getIPlayer(ev.player);
if (MineTweakerMod.INSTANCE.recipes.hasTransformerRecipes()) { if (MCRecipeManager.hasTransformerRecipes()) {
MineTweakerMod.INSTANCE.recipes.applyTransformations(MCCraftingInventory.get(ev.craftMatrix, ev.player), iPlayer); MCRecipeManager.applyTransformations(MCCraftingInventory.get(ev.craftMatrix, ev.player), iPlayer);
} }
if (MineTweakerImplementationAPI.events.hasPlayerCrafted()) { if (MineTweakerImplementationAPI.events.hasPlayerCrafted()) {
@@ -7,6 +7,8 @@
package minetweaker.mc1710; package minetweaker.mc1710;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import minetweaker.*; import minetweaker.*;
import minetweaker.api.entity.*; import minetweaker.api.entity.*;
import minetweaker.api.formatting.IFormattedText; import minetweaker.api.formatting.IFormattedText;
@@ -15,10 +17,12 @@ import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.tooltip.IngredientTooltips; import minetweaker.api.tooltip.IngredientTooltips;
import minetweaker.mc1710.formatting.IMCFormattedString; import minetweaker.mc1710.formatting.IMCFormattedString;
import minetweaker.mc1710.item.*; import minetweaker.mc1710.item.*;
import net.minecraft.client.multiplayer.GuiConnecting;
import net.minecraft.entity.*; import net.minecraft.entity.*;
import net.minecraft.entity.item.*; import net.minecraft.entity.item.*;
import net.minecraft.entity.player.*; import net.minecraft.entity.player.*;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.event.entity.living.*; import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent;
@@ -42,6 +46,12 @@ public class ForgeEventHandler {
MineTweakerImplementationAPI.events.publishPlayerInteract(event); MineTweakerImplementationAPI.events.publishPlayerInteract(event);
} }
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlayerGuiOpen(GuiOpenEvent ev) {
if (ev.gui != null && ev.gui instanceof GuiConnecting) MineTweakerMod.INSTANCE.onClientAboutToConnect();
}
@SubscribeEvent @SubscribeEvent
public void onItemTooltip(ItemTooltipEvent ev) { public void onItemTooltip(ItemTooltipEvent ev) {
if(ev.itemStack!= null) { if(ev.itemStack!= null) {
@@ -32,7 +32,7 @@ public class MCPlatformFunctions implements IPlatformFunctions {
@Override @Override
public void distributeScripts(byte[] data) { public void distributeScripts(byte[] data) {
MineTweakerMod.NETWORK.sendToAll(new MineTweakerLoadScriptsPacket(data)); if (MineTweakerConfig.sendScriptsOnReloading) MineTweakerMod.NETWORK.sendToAll(new MineTweakerLoadScriptsPacket(data));
} }
@Override @Override
@@ -0,0 +1,32 @@
package minetweaker.mc1710;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
public class MineTweakerConfig {
private MineTweakerConfig() { }
public static boolean handleDesktopPackets = false, handleLoadScripts = true, sendLoadScripts = true,
sendScriptsOnReloading = true, loadScriptsBeforeConnection = false, antiStuck = true;
static File file;
public static void load() {
Configuration config = new Configuration(file, "1");
config.load();
handleDesktopPackets = config.getBoolean("handleDesktopPackets",
"network", false, "Handle OpenBrowser and CopyClipboard packets? Insecure.");
handleLoadScripts = config.getBoolean("handleLoadScripts", "network", true,
"Proccess LoadScripts packet on client? Insecure, takes time, but update scripts on the fly...");
sendLoadScripts = config.getBoolean("sendLoadScripts",
"network", true, "Send scripts to players on logging in");
sendScriptsOnReloading = config.getBoolean("sendScriptsOnReloading",
"network", true, "Send scripts to players on command \"mt reload\"");
loadScriptsBeforeConnection = config.getBoolean("loadScriptsBeforeConnection",
"core", false, "Load scripts before connect to server? Save time and traffic. Requires server with disabled sendLoadScripts.");
antiStuck = config.getBoolean("antiStuck",
"core", false, "Do not reload scripts when relogging, saves time. Usable when playing on one server/singleplayer...");
config.save();
}
}
@@ -35,10 +35,14 @@ import minetweaker.runtime.*;
import minetweaker.runtime.providers.ScriptProviderCascade; import minetweaker.runtime.providers.ScriptProviderCascade;
import minetweaker.runtime.providers.ScriptProviderCustom; import minetweaker.runtime.providers.ScriptProviderCustom;
import minetweaker.runtime.providers.ScriptProviderDirectory; import minetweaker.runtime.providers.ScriptProviderDirectory;
import net.minecraft.client.Minecraft;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import java.io.File; import java.io.File;
import java.util.List;
/** /**
* Main mod class. Performs some general logic, initialization of the API and * Main mod class. Performs some general logic, initialization of the API and
@@ -77,20 +81,22 @@ public class MineTweakerMod {
@Mod.Instance(MODID) @Mod.Instance(MODID)
public static MineTweakerMod INSTANCE; public static MineTweakerMod INSTANCE;
public final MCRecipeManager recipes;
private final IScriptProvider scriptsGlobal; private final IScriptProvider scriptsGlobal;
private final ScriptProviderCustom scriptsIMC; private final ScriptProviderCustom scriptsIMC;
private volatile boolean loaded = false;
public MineTweakerMod() { public MineTweakerMod() {
MCRecipeManager.recipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList();
MineTweakerImplementationAPI.init( MineTweakerImplementationAPI.init(
new MCOreDict(), new MCOreDict(),
recipes = new MCRecipeManager(), new MCRecipeManager(),
new MCFurnaceManager(), new MCFurnaceManager(),
MCGame.INSTANCE, MCGame.INSTANCE,
new MCLoadedMods(), new MCLoadedMods(),
new MCFormatter(), new MCFormatter(),
new MCVanilla()); new MCVanilla());
MineTweakerImplementationAPI.logger.addLogger(new FileLogger(new File("minetweaker.log"))); MineTweakerImplementationAPI.logger.addLogger(new FileLogger(new File("minetweaker.log")));
MineTweakerImplementationAPI.platform = MCPlatformFunctions.INSTANCE; MineTweakerImplementationAPI.platform = MCPlatformFunctions.INSTANCE;
@@ -123,6 +129,8 @@ public class MineTweakerMod {
@EventHandler @EventHandler
public void onLoad(FMLPreInitializationEvent ev) { public void onLoad(FMLPreInitializationEvent ev) {
MineTweakerConfig.file = new File(ev.getModConfigurationDirectory(), MODID + ".cfg");
MineTweakerConfig.load();
MinecraftForge.EVENT_BUS.register(new ForgeEventHandler()); MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());
FMLCommonHandler.instance().bus().register(new FMLEventHandler()); FMLCommonHandler.instance().bus().register(new FMLEventHandler());
} }
@@ -144,17 +152,13 @@ public class MineTweakerMod {
ItemBracketHandler.rebuildItemRegistry(); ItemBracketHandler.rebuildItemRegistry();
LiquidBracketHandler.rebuildLiquidRegistry(); LiquidBracketHandler.rebuildLiquidRegistry();
MineTweakerAPI.logInfo("MineTweaker: Sucessfully built item registry"); MineTweakerAPI.logInfo("MineTweaker: Sucessfully built item registry");
if (MineTweakerPlatformUtils.isClient()) {
MineTweakerAPI.client = new MCClient();
}
} }
@EventHandler @EventHandler
public void onServerAboutToStart(FMLServerAboutToStartEvent ev) { public void onServerAboutToStart(FMLServerAboutToStartEvent ev) {
// starts before loading worlds
// perfect place to start MineTweaker!
if (MineTweakerPlatformUtils.isClient()) {
MineTweakerAPI.client = new MCClient();
}
File scriptsDir = new File(MineTweakerHacks.getWorldDirectory(ev.getServer()), "scripts"); File scriptsDir = new File(MineTweakerHacks.getWorldDirectory(ev.getServer()), "scripts");
if (!scriptsDir.exists()) { if (!scriptsDir.exists()) {
scriptsDir.mkdir(); scriptsDir.mkdir();
@@ -164,12 +168,21 @@ public class MineTweakerMod {
IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal,scriptsLocal); IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal,scriptsLocal);
MineTweakerImplementationAPI.setScriptProvider(cascaded); MineTweakerImplementationAPI.setScriptProvider(cascaded);
MineTweakerImplementationAPI.onServerStart(new MCServer(ev.getServer())); MCServer srv = new MCServer(ev.getServer());
if (loaded && MineTweakerConfig.antiStuck) MineTweakerAPI.server = srv;
else {
MineTweakerImplementationAPI.onServerStart(srv);
loaded = true;
}
} }
@EventHandler public void onClientAboutToConnect() {
public void onServerStarting(FMLServerStartingEvent ev) { if (!MineTweakerConfig.loadScriptsBeforeConnection) return;
IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal);
MineTweakerImplementationAPI.setScriptProvider(cascaded);
if (loaded && MineTweakerConfig.antiStuck) return;
MineTweakerImplementationAPI.reload();
loaded = true;
} }
@EventHandler @EventHandler
@@ -53,7 +53,7 @@ public class MCItemStack implements IItemStack {
throw new IllegalArgumentException("stack cannot be null"); throw new IllegalArgumentException("stack cannot be null");
stack = itemStack.copy(); stack = itemStack.copy();
items = Collections.<IItemStack>singletonList(this); items = Collections.singletonList(this);
} }
public MCItemStack(ItemStack itemStack, boolean wildcardSize) { public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
@@ -67,13 +67,13 @@ public class MCItemStack implements IItemStack {
throw new IllegalArgumentException("stack cannot be null"); throw new IllegalArgumentException("stack cannot be null");
stack = itemStack; stack = itemStack;
items = Collections.<IItemStack>singletonList(this); items = Collections.singletonList(this);
this.tag = tag; this.tag = tag;
} }
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) { private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
stack = itemStack; stack = itemStack;
items = Collections.<IItemStack>singletonList(this); items = Collections.singletonList(this);
this.tag = tag; this.tag = tag;
this.wildcardSize = wildcardSize; this.wildcardSize = wildcardSize;
} }
@@ -9,6 +9,8 @@ package minetweaker.mc1710.network;
import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import minetweaker.mc1710.MineTweakerConfig;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
@@ -21,7 +23,7 @@ import java.awt.datatransfer.StringSelection;
public class MineTweakerCopyClipboardHandler implements IMessageHandler<MineTweakerCopyClipboardPacket, IMessage> { public class MineTweakerCopyClipboardHandler implements IMessageHandler<MineTweakerCopyClipboardPacket, IMessage> {
@Override @Override
public IMessage onMessage(MineTweakerCopyClipboardPacket message, MessageContext ctx) { public IMessage onMessage(MineTweakerCopyClipboardPacket message, MessageContext ctx) {
if (Desktop.isDesktopSupported()) { if (Desktop.isDesktopSupported() && MineTweakerConfig.handleDesktopPackets) {
StringSelection stringSelection = new StringSelection(message.getData()); StringSelection stringSelection = new StringSelection(message.getData());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null); clipboard.setContents(stringSelection, null);
@@ -11,7 +11,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import minetweaker.MineTweakerAPI; import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI; import minetweaker.MineTweakerImplementationAPI;
import minetweaker.mc1710.client.MCClient; import minetweaker.mc1710.MineTweakerConfig;
import minetweaker.runtime.providers.ScriptProviderMemory; import minetweaker.runtime.providers.ScriptProviderMemory;
/** /**
@@ -21,13 +21,10 @@ import minetweaker.runtime.providers.ScriptProviderMemory;
public class MineTweakerLoadScriptsHandler implements IMessageHandler<MineTweakerLoadScriptsPacket, IMessage> { public class MineTweakerLoadScriptsHandler implements IMessageHandler<MineTweakerLoadScriptsPacket, IMessage> {
@Override @Override
public IMessage onMessage(MineTweakerLoadScriptsPacket message, MessageContext ctx) { public IMessage onMessage(MineTweakerLoadScriptsPacket message, MessageContext ctx) {
if (MineTweakerAPI.server == null) { if (MineTweakerAPI.server == null && MineTweakerConfig.handleLoadScripts) {
MineTweakerAPI.client = new MCClient();
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderMemory(message.getData())); MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderMemory(message.getData()));
MineTweakerImplementationAPI.reload(); MineTweakerImplementationAPI.reload();
} }
return null; return null;
} }
} }
@@ -9,6 +9,8 @@ package minetweaker.mc1710.network;
import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import minetweaker.mc1710.MineTweakerConfig;
import java.awt.Desktop; import java.awt.Desktop;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
@@ -21,15 +23,13 @@ import java.net.URISyntaxException;
public class MineTweakerOpenBrowserHandler implements IMessageHandler<MineTweakerOpenBrowserPacket, IMessage> { public class MineTweakerOpenBrowserHandler implements IMessageHandler<MineTweakerOpenBrowserPacket, IMessage> {
@Override @Override
public IMessage onMessage(MineTweakerOpenBrowserPacket message, MessageContext ctx) { public IMessage onMessage(MineTweakerOpenBrowserPacket message, MessageContext ctx) {
if (Desktop.isDesktopSupported()) { if (Desktop.isDesktopSupported() && MineTweakerConfig.handleDesktopPackets) {
Desktop desktop = Desktop.getDesktop(); Desktop desktop = Desktop.getDesktop();
try { try {
desktop.browse(new URI(message.getUrl())); desktop.browse(new URI(message.getUrl()));
} catch (IOException e) { } catch (IOException e) {
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
} }
} else {
System.out.println("Desktop not supported");
} }
return null; return null;
@@ -12,6 +12,7 @@ import minetweaker.api.data.IData;
import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC; import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer; import minetweaker.api.player.IPlayer;
import minetweaker.mc1710.MineTweakerConfig;
import minetweaker.mc1710.MineTweakerMod; import minetweaker.mc1710.MineTweakerMod;
import minetweaker.mc1710.data.NBTConverter; import minetweaker.mc1710.data.NBTConverter;
import minetweaker.mc1710.network.MineTweakerCopyClipboardPacket; import minetweaker.mc1710.network.MineTweakerCopyClipboardPacket;
@@ -126,7 +127,7 @@ public class MCPlayer implements IPlayer {
@Override @Override
public void openBrowser(String url) { public void openBrowser(String url) {
if (player instanceof EntityPlayerMP) { if (player instanceof EntityPlayerMP && MineTweakerConfig.handleDesktopPackets) {
MineTweakerMod.NETWORK.sendTo( MineTweakerMod.NETWORK.sendTo(
new MineTweakerOpenBrowserPacket(url), new MineTweakerOpenBrowserPacket(url),
(EntityPlayerMP) player); (EntityPlayerMP) player);
@@ -135,7 +136,7 @@ public class MCPlayer implements IPlayer {
@Override @Override
public void copyToClipboard(String value) { public void copyToClipboard(String value) {
if (player instanceof EntityPlayerMP) { if (player instanceof EntityPlayerMP && MineTweakerConfig.handleDesktopPackets) {
MineTweakerMod.NETWORK.sendTo( MineTweakerMod.NETWORK.sendTo(
new MineTweakerCopyClipboardPacket(value), new MineTweakerCopyClipboardPacket(value),
(EntityPlayerMP) player); (EntityPlayerMP) player);
@@ -2,12 +2,21 @@ package minetweaker.mc1710.recipes;
import minetweaker.IUndoableAction; import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI; import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.item.IIngredient; import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC; import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer; import minetweaker.api.player.IPlayer;
import minetweaker.api.recipes.*; import minetweaker.api.recipes.ICraftingInventory;
import minetweaker.api.recipes.ICraftingRecipe;
import minetweaker.api.recipes.IRecipeAction;
import minetweaker.api.recipes.IRecipeFunction;
import minetweaker.api.recipes.IRecipeManager;
import minetweaker.api.recipes.ShapedRecipe;
import minetweaker.api.recipes.ShapelessRecipe;
import minetweaker.mc1710.item.MCItemStack;
import minetweaker.mc1710.util.MineTweakerHacks; import minetweaker.mc1710.util.MineTweakerHacks;
import minetweaker.util.IEventHandler;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
@@ -18,30 +27,42 @@ import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.apache.commons.lang3.tuple.Pair;
import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.Optional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set;
import static minetweaker.api.minecraft.MineTweakerMC.*; import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getOreDict;
/** /**
* @author Stan * @author Stan
*/ */
public class MCRecipeManager implements IRecipeManager { public final class MCRecipeManager implements IRecipeManager {
private final List<IRecipe> recipes; public static final List<ActionBaseAddRecipe> recipesToAdd = new ArrayList<>();
private final List<ICraftingRecipe> transformerRecipes; public static final List<ActionBaseRemoveRecipes> recipesToRemove = new ArrayList<>();
public static final ActionRemoveRecipesNoIngredients actionRemoveRecipesNoIngredients = new ActionRemoveRecipesNoIngredients();
public static final List<IRecipe> recipesToUndo = new ArrayList<>();
public static List<IRecipe> recipes;
public static final List<ICraftingRecipe> transformerRecipes = new ArrayList<>();
public MCRecipeManager() { public MCRecipeManager() {
recipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList(); MineTweakerImplementationAPI.onPostReload(new HandleLateAdditionsAndRemovals());
transformerRecipes = new ArrayList<ICraftingRecipe>(); MineTweakerImplementationAPI.onRollbackEvent(new HandleLateAdditionsAndRemovals());
} }
public boolean hasTransformerRecipes() { public static boolean hasTransformerRecipes() {
return transformerRecipes.size() > 0; return transformerRecipes.size() > 0;
} }
public void applyTransformations(ICraftingInventory inventory, IPlayer byPlayer) { public static void applyTransformations(ICraftingInventory inventory, IPlayer byPlayer) {
for (ICraftingRecipe recipe : transformerRecipes) { for (ICraftingRecipe recipe : transformerRecipes) {
if (recipe.matches(inventory)) { if (recipe.matches(inventory)) {
recipe.applyTransformers(inventory, byPlayer); recipe.applyTransformers(inventory, byPlayer);
@@ -50,9 +71,35 @@ public class MCRecipeManager implements IRecipeManager {
} }
} }
private static boolean matches(Object input, IIngredient ingredient) {
if ((input == null) != (ingredient == null)) {
return false;
} else if (ingredient != null) {
if (input instanceof ItemStack) {
return ingredient.matches(getIItemStack((ItemStack) input));
} else if (input instanceof String) {
return ingredient.contains(getOreDict((String) input));
}
}
return true;
}
@Override
public List<ICraftingRecipe> getAll() {
List<ICraftingRecipe> results = new ArrayList<>();
for (IRecipe recipe : recipes) {
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
results.add(converted);
}
return results;
}
@Override @Override
public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient) { public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient) {
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>(); List<ICraftingRecipe> results = new ArrayList<>();
for (IRecipe recipe : recipes) { for (IRecipe recipe : recipes) {
if (ingredient.matches(MineTweakerMC.getIItemStack(recipe.getRecipeOutput()))) { if (ingredient.matches(MineTweakerMC.getIItemStack(recipe.getRecipeOutput()))) {
@@ -65,203 +112,129 @@ public class MCRecipeManager implements IRecipeManager {
} }
@Override @Override
public List<ICraftingRecipe> getAll() { public int remove(IIngredient output) {
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>(); return remove(output, false);
for (IRecipe recipe : recipes) {
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
results.add(converted);
}
return results;
} }
@Override @Override
public int remove(IIngredient output, @Optional boolean nbtMatch) { public int remove(IIngredient output, @Optional boolean nbtMatch) {
List<IRecipe> toRemove = new ArrayList<IRecipe>(); if(output == null) {
List<Integer> removeIndex = new ArrayList<Integer>(); MineTweakerAPI.logError("Cannot remove recipes for a null item!");
for (int i = 0; i < recipes.size(); i++) { return 0;
IRecipe recipe = recipes.get(i);
// certain special recipes have no predefined output. ignore those
// since these cannot be removed with MineTweaker scripts
if (recipe.getRecipeOutput() != null) {
if (nbtMatch ? output.matchesExact(getIItemStack(recipe.getRecipeOutput())) : output.matches(getIItemStack(recipe.getRecipeOutput()))) {
toRemove.add(recipe);
removeIndex.add(i);
}
}
} }
actionRemoveRecipesNoIngredients.addOutput(output, nbtMatch);
return 1;
}
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex)); @Override
return toRemove.size(); public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) {
recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, null, false));
}
@Override
public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action) {
recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, action, false));
}
@Override
public void addShaped(IItemStack output, IIngredient[][] ingredients) {
recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, null, false));
} }
@Override @Override
public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action) { public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action) {
addShaped(output, ingredients, function, action, false); recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, action, false));
}
@Override
public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) {
recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, null, true));
}
@Override
public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients) {
recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, null, true));
}
@Override
public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeAction action) {
recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, action, true));
} }
@Override @Override
public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action) { public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action) {
addShaped(output, ingredients, function, action, true); recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, action, true));
} }
@Override @Override
public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) { public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) {
ShapelessRecipe recipe = new ShapelessRecipe(output, ingredients, function, action); if(checkShapelessNulls(output, ingredients))
IRecipe irecipe = RecipeConverter.convert(recipe); return;
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
recipesToAdd.add(new ActionAddShapelessRecipe(output, ingredients, function, action));
}
@Override
public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function){
addShapeless(output, ingredients, function, null);
}
@Override
public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeAction action){
addShapeless(output, ingredients, null, action);
}
@Override
public void addShapeless(IItemStack output, IIngredient[] ingredients){
addShapeless(output, ingredients, null, null);
}
private boolean checkShapelessNulls(IItemStack output, IIngredient[] ingredients) {
if(output != null && Arrays.stream(ingredients).allMatch(Objects::isNull)) {
MineTweakerAPI.logError("Null not allowed in shapeless recipes! Recipe for: " + output + " not created!");
return true;
}
return false;
} }
@Override @Override
public int removeShaped(IIngredient output, IIngredient[][] ingredients) { public int removeShaped(IIngredient output, IIngredient[][] ingredients) {
int ingredientsWidth = 0; if(output == null) {
int ingredientsHeight = 0; MineTweakerAPI.logError("Cannot remove recipes for a null item!");
return 0;
if (ingredients != null) {
ingredientsHeight = ingredients.length;
for (int i = 0; i < ingredients.length; i++) {
ingredientsWidth = Math.max(ingredientsWidth, ingredients[i].length);
}
} }
recipesToRemove.add(new ActionRemoveShapedRecipes(output, ingredients));
return 1;
}
List<IRecipe> toRemove = new ArrayList<IRecipe>(); @Override
List<Integer> removeIndex = new ArrayList<Integer>(); public int removeShaped(IIngredient output) {
outer: return removeShaped(output, null);
for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
if (recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
continue;
}
if (ingredients != null) {
if (recipe instanceof ShapedRecipes) {
ShapedRecipes srecipe = (ShapedRecipes) recipe;
if (ingredientsWidth != srecipe.recipeWidth || ingredientsHeight != srecipe.recipeHeight) {
continue;
}
for (int j = 0; j < ingredientsHeight; j++) {
IIngredient[] row = ingredients[j];
for (int k = 0; k < ingredientsWidth; k++) {
IIngredient ingredient = k > row.length ? null : row[k];
ItemStack recipeIngredient = srecipe.recipeItems[j * srecipe.recipeWidth + k];
if (!matches(recipeIngredient, ingredient)) {
continue outer;
}
}
}
} else if (recipe instanceof ShapedOreRecipe) {
ShapedOreRecipe srecipe = (ShapedOreRecipe) recipe;
int recipeWidth = MineTweakerHacks.getShapedOreRecipeWidth(srecipe);
int recipeHeight = srecipe.getRecipeSize() / recipeWidth;
if (ingredientsWidth != recipeWidth || ingredientsHeight != recipeHeight) {
continue;
}
for (int j = 0; j < ingredientsHeight; j++) {
IIngredient[] row = ingredients[j];
for (int k = 0; k < ingredientsWidth; k++) {
IIngredient ingredient = k > row.length ? null : row[k];
Object input = srecipe.getInput()[j * recipeWidth + k];
if (!matches(input, ingredient)) {
continue outer;
}
}
}
}
} else {
if (recipe instanceof ShapedRecipes) {
} else if (recipe instanceof ShapedOreRecipe) {
} else {
continue;
}
}
toRemove.add(recipe);
removeIndex.add(i);
}
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
return toRemove.size();
} }
@Override @Override
public int removeShapeless(IIngredient output, IIngredient[] ingredients, boolean wildcard) { public int removeShapeless(IIngredient output, IIngredient[] ingredients, boolean wildcard) {
List<IRecipe> toRemove = new ArrayList<IRecipe>(); if(output == null) {
List<Integer> removeIndex = new ArrayList<Integer>(); MineTweakerAPI.logError("Cannot remove recipes for a null item!");
outer: return 0;
for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
if (recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
continue;
}
if (ingredients != null) {
if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes srecipe = (ShapelessRecipes) recipe;
if (ingredients.length > srecipe.getRecipeSize()) {
continue;
} else if (!wildcard && ingredients.length < srecipe.getRecipeSize()) {
continue;
}
checkIngredient:
for (int j = 0; j < ingredients.length; j++) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(srecipe.recipeItems.get(k), ingredients[j])) {
continue checkIngredient;
}
}
continue outer;
}
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe srecipe = (ShapelessOreRecipe) recipe;
ArrayList<Object> inputs = srecipe.getInput();
if (inputs.size() < ingredients.length) {
continue;
}
if (!wildcard && inputs.size() > ingredients.length) {
continue;
}
checkIngredient:
for (int j = 0; j < ingredients.length; j++) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(inputs.get(k), ingredients[j])) {
continue checkIngredient;
}
}
continue outer;
}
}
} else {
if (recipe instanceof ShapelessRecipes) {
} else if (recipe instanceof ShapelessOreRecipe) {
} else {
continue;
}
}
toRemove.add(recipe);
removeIndex.add(i);
} }
recipesToRemove.add(new ActionRemoveShapelessRecipes(output, ingredients, wildcard));
return 1;
}
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex)); @Override
return toRemove.size(); public int removeShapeless(IIngredient output, IIngredient[] ingredients) {
return removeShapeless(output, ingredients, false);
}
@Override
public int removeShapeless(IIngredient output, boolean wildcard) {
return removeShapeless(output, null, wildcard);
}
@Override
public int removeShapeless(IIngredient output) {
return removeShapeless(output, null, true);
} }
@Override @Override
@@ -294,6 +267,390 @@ public class MCRecipeManager implements IRecipeManager {
return getIItemStack(result); return getIItemStack(result);
} }
} }
public abstract static class ActionBaseRemoveRecipes implements IUndoableAction {
public void removeRecipes(Set<IRecipe> toRemove ) {
recipes.removeIf(toRemove::contains);
}
}
public static class ActionRemoveRecipesNoIngredients extends ActionBaseRemoveRecipes implements IUndoableAction {
// pair of output, nbtMatch
private final List<Pair<IIngredient, Boolean>> outputs = new ArrayList<>();
private final Set<IRecipe> toRemove = new HashSet<>();
public void addOutput(IIngredient output, @Optional boolean nbtMatch) {
outputs.add(Pair.of(output, nbtMatch));
}
public void clearOutputs() {
outputs.clear();
}
@Override
public void apply() {
toRemove.clear();
for (final IRecipe recipe : recipes) {
final ItemStack recipeOutput = recipe.getRecipeOutput();
if (recipeOutput != null) {
final IItemStack stack = getIItemStack(recipeOutput);
if (matches(stack)) {
toRemove.add(recipe);
}
}
}
super.removeRecipes(toRemove);
}
@Override
public boolean canUndo() {
return !toRemove.isEmpty();
}
@Override
public void undo() {
for(IRecipe recipe: toRemove) {
recipesToAdd.add(new ActionBaseAddRecipe(recipe));
}
}
@Override
public String describe() {
return "Removing recipes for various outputs";
}
@Override
public String describeUndo() {
return "Trying to restore " + toRemove.size() + " recipes.";
}
@Override
public Object getOverrideKey() {
return null;
}
private boolean matches(IItemStack stack) {
for(Pair<IIngredient, Boolean> entry : outputs) {
IIngredient output = entry.getKey();
Boolean nbtMatch = entry.getValue();
if(nbtMatch ? output.matchesExact(stack) : output.matches(stack)) {
return true;
}
}
return false;
}
}
public static class ActionRemoveShapelessRecipes extends ActionBaseRemoveRecipes implements IUndoableAction {
final IIngredient output;
final IIngredient[] ingredients;
final boolean wildcard;
Set<IRecipe> toRemove = new HashSet<>();
public ActionRemoveShapelessRecipes(IIngredient output, IIngredient[] ingredients, boolean wildcard) {
this.output = output;
this.ingredients = ingredients;
this.wildcard = wildcard;
}
@Override
public void apply() {
toRemove.clear();
outer:
for (IRecipe recipe : recipes) {
if (recipe.getRecipeOutput() == null || !output.matches(new MCItemStack(recipe.getRecipeOutput()))) {
continue;
}
if (recipe instanceof ShapedRecipes) {
continue;
}
if (!(recipe instanceof ShapelessRecipes) && !(recipe instanceof ShapelessOreRecipe)) {
continue;
}
if (ingredients != null) {
if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes srecipe = (ShapelessRecipes) recipe;
if (ingredients.length > srecipe.getRecipeSize()) {
continue;
} else if (!wildcard && ingredients.length < srecipe.getRecipeSize()) {
continue;
}
checkIngredient:
for (IIngredient ingredient : ingredients) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(srecipe.recipeItems.get(k), ingredient)) {
continue checkIngredient;
}
}
continue outer;
}
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe srecipe = (ShapelessOreRecipe) recipe;
ArrayList<Object> inputs = srecipe.getInput();
if (inputs.size() < ingredients.length) {
continue;
}
if (!wildcard && inputs.size() > ingredients.length) {
continue;
}
checkIngredient:
for (IIngredient ingredient : ingredients) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(inputs.get(k), ingredient)) {
continue checkIngredient;
}
}
continue outer;
}
}
}
toRemove.add(recipe);
}
MineTweakerAPI.logInfo("Removing " + toRemove.size() + " Shapeless recipes.");
super.removeRecipes(toRemove);
}
@Override
public boolean canUndo() {
return !toRemove.isEmpty();
}
@Override
public void undo() {
for(IRecipe recipe: toRemove) {
recipesToAdd.add(new ActionBaseAddRecipe(recipe));
}
}
@Override
public String describe() {
if(output != null) {
return "Removing Shapeless recipes for " + output.toString();
} else {
return "Trying to remove recipes for invalid output";
}
}
@Override
public String describeUndo() {
return "Trying to restore " + toRemove.size() + " shapeless recipes.";
}
@Override
public Object getOverrideKey() {
return null;
}
}
public static class ActionRemoveShapedRecipes extends ActionBaseRemoveRecipes implements IUndoableAction {
final IIngredient output;
final IIngredient[][] ingredients;
final Set<IRecipe> toRemove = new HashSet<>();
public ActionRemoveShapedRecipes(IIngredient output, IIngredient[][] ingredients) {
this.output = output;
this.ingredients = ingredients;
}
@Override
public void apply() {
int ingredientsWidth = 0;
int ingredientsHeight = 0;
toRemove.clear();
if (ingredients != null) {
ingredientsHeight = ingredients.length;
for (IIngredient[] ingredient : ingredients) {
ingredientsWidth = Math.max(ingredientsWidth, ingredient.length);
}
}
outer:
for (final IRecipe recipe : recipes) {
final ItemStack output = recipe.getRecipeOutput();
if (output == null || !this.output.matches(new MCItemStack(output))) {
continue;
}
if (!(recipe instanceof ShapedRecipes || recipe instanceof ShapedOreRecipe))
continue;
if (ingredients != null) {
boolean ore = recipe instanceof ShapedOreRecipe;
final ShapedRecipes shapedRecipe = !ore ? (ShapedRecipes) recipe : null;
final ShapedOreRecipe shapedOreRecipe = ore ? (ShapedOreRecipe) recipe : null;
final int recipeWidth = ore ? MineTweakerHacks.getShapedOreRecipeWidth(shapedOreRecipe) : shapedRecipe.recipeWidth;
final int recipeHeight = ore ? shapedOreRecipe.getRecipeSize() / recipeWidth : shapedRecipe.recipeHeight;
if (ingredientsWidth != recipeWidth || ingredientsHeight != recipeHeight) {
continue;
}
for (int j = 0; j < ingredientsHeight; j++) {
final IIngredient[] row = ingredients[j];
for (int k = 0; k < ingredientsWidth; k++) {
final IIngredient ingredient = k > row.length ? null : row[k];
final Object input = (ore ? shapedOreRecipe.getInput() : shapedRecipe.recipeItems)[j * recipeWidth + k];
if (!matches(input, ingredient)) {
continue outer;
}
}
}
}
// If null ingredient list given, remove all ShapedRecipes with the given output
toRemove.add(recipe);
}
MineTweakerAPI.logInfo(toRemove.size() + " removed");
super.removeRecipes(toRemove);
}
@Override
public boolean canUndo() {
return !toRemove.isEmpty();
}
@Override
public void undo() {
for(IRecipe recipe: toRemove) {
recipesToAdd.add(new ActionBaseAddRecipe(recipe));
}
}
@Override
public String describe() {
if(output != null) {
return "Removing Shaped recipes for " + output.toString();
} else {
return "Trying to remove recipes for invalid output";
}
}
@Override
public String describeUndo() {
return "Trying to restore " + toRemove.size() + " shaped recipes.";
}
@Override
public Object getOverrideKey() {
return null;
}
}
public static class ActionBaseAddRecipe implements IUndoableAction {
private final IRecipe iRecipe;
private final ICraftingRecipe craftingRecipe;
protected final IItemStack output;
protected final boolean isShaped;
protected final boolean isRestoring;
private ActionBaseAddRecipe(IRecipe iRecipe) {
this.iRecipe = iRecipe;
this.craftingRecipe = null;
this.isRestoring = true;
this.isShaped = iRecipe instanceof ShapedRecipes;
this.output = new MCItemStack(iRecipe.getRecipeOutput());
}
private ActionBaseAddRecipe(ICraftingRecipe craftingRecipe, IItemStack output, boolean isShaped) {
this.iRecipe = RecipeConverter.convert(craftingRecipe);
this.craftingRecipe = craftingRecipe;
this.isRestoring = false;
this.output = output;
this.isShaped = isShaped;
}
@Override
public void apply() {
recipes.add(iRecipe);
if (craftingRecipe != null && craftingRecipe.hasTransformers())
transformerRecipes.add(craftingRecipe);
}
@Override
public boolean canUndo() {
return iRecipe != null;
}
@Override
public void undo() {
recipesToUndo.add(iRecipe);
}
@Override
public String describe() {
if(output != null) {
return "" + (this.isRestoring ? "Restoring" : "Adding ") + (isShaped ? "shaped" : "shapeless") + " recipe for " + output.getDisplayName();
} else {
return "Trying to add " + (isShaped ? "shaped" : "shapeless") + "recipe without correct output";
}
}
@Override
public String describeUndo() {
return "Undoing addition of " + output.getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class ActionAddShapedRecipe extends ActionBaseAddRecipe {
public ActionAddShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
super(new ShapedRecipe(output, ingredients, function, action, mirrored), output, true);
}
}
private static class ActionAddShapelessRecipe extends ActionBaseAddRecipe {
public ActionAddShapelessRecipe(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) {
super(new ShapelessRecipe(output, ingredients, function, action), output, false);
}
}
public static void applyAdditionsAndRemovals() {
System.out.println("MineTweaker: Applying additions and removals");
MineTweakerAPI.apply(MCRecipeManager.actionRemoveRecipesNoIngredients);
if(recipesToUndo.size() > 0) {
recipes.removeIf(recipesToUndo::contains);
}
MCRecipeManager.recipesToRemove.forEach(MineTweakerAPI::apply);
MCRecipeManager.recipesToAdd.forEach(MineTweakerAPI::apply);
actionRemoveRecipesNoIngredients.clearOutputs();
recipesToRemove.clear();;
recipesToAdd.clear();
recipesToUndo.clear();
}
public static class HandleLateAdditionsAndRemovals implements IEventHandler<MineTweakerImplementationAPI.ReloadEvent>
{
@Override
public void handle(MineTweakerImplementationAPI.ReloadEvent event)
{
MCRecipeManager.applyAdditionsAndRemovals();
}
}
private class ContainerVirtual extends Container { private class ContainerVirtual extends Container {
@Override @Override
@@ -301,119 +658,5 @@ public class MCRecipeManager implements IRecipeManager {
return false; return false;
} }
} }
private class ActionRemoveRecipes implements IUndoableAction {
private final List<Integer> removingIndices;
private final List<IRecipe> removingRecipes;
public ActionRemoveRecipes(List<IRecipe> recipes, List<Integer> indices) {
this.removingIndices = indices;
this.removingRecipes = recipes;
}
@Override
public void apply() {
for (int i = removingIndices.size() - 1; i >= 0; i--) {
recipes.remove((int) removingIndices.get(i));
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
for (int i = 0; i < removingIndices.size(); i++) {
int index = Math.min(recipes.size(), removingIndices.get(i));
recipes.add(index, removingRecipes.get(i));
}
}
@Override
public String describe() {
return "Removing " + removingIndices.size() + " recipes";
}
@Override
public String describeUndo() {
return "Restoring " + removingIndices.size() + " recipes";
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class ActionAddRecipe implements IUndoableAction {
private final IRecipe recipe;
private final ICraftingRecipe craftingRecipe;
public ActionAddRecipe(IRecipe recipe, ICraftingRecipe craftingRecipe) {
this.recipe = recipe;
this.craftingRecipe = craftingRecipe;
}
@Override
public void apply() {
recipes.add(recipe);
if (craftingRecipe.hasTransformers()) {
transformerRecipes.add(craftingRecipe);
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
recipes.remove(recipe);
if (craftingRecipe.hasTransformers()) {
transformerRecipes.remove(craftingRecipe);
}
}
@Override
public String describe() {
return "Adding recipe for " + recipe.getRecipeOutput().getDisplayName();
}
@Override
public String describeUndo() {
return "Removing recipe for " + recipe.getRecipeOutput().getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
private void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
ShapedRecipe recipe = new ShapedRecipe(output, ingredients, function, action, mirrored);
IRecipe irecipe = RecipeConverter.convert(recipe);
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
}
private static boolean matches(Object input, IIngredient ingredient) {
if ((input == null) != (ingredient == null)) {
return false;
} else if (ingredient != null) {
if (input instanceof ItemStack) {
if (!ingredient.matches(getIItemStack((ItemStack) input))) {
return false;
}
} else if (input instanceof String) {
if (!ingredient.contains(getOreDict((String) input))) {
return false;
}
}
}
return true;
}
} }
@@ -53,7 +53,13 @@ public class RecipeConverter {
} }
return type; return type;
} }
public static IRecipe convert(ICraftingRecipe recipe) {
if (recipe instanceof ShapedRecipe)
return RecipeConverter.convert((ShapedRecipe)recipe);
else
return RecipeConverter.convert((ShapelessRecipe) recipe);
}
public static IRecipe convert(ShapelessRecipe recipe) { public static IRecipe convert(ShapelessRecipe recipe) {
IIngredient[] ingredients = recipe.getIngredients(); IIngredient[] ingredients = recipe.getIngredients();
int type = getRecipeType(ingredients); int type = getRecipeType(ingredients);
+3 -21
View File
@@ -1,28 +1,9 @@
import minetweaker.tasks.RegisterZenClassesTask; import minetweaker.tasks.RegisterZenClassesTask;
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
apply plugin: 'forge' apply plugin: 'forge'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft { minecraft {
version = forgeVersion1710 version = forgeVersion1710
@@ -39,8 +20,9 @@ dependencies {
} }
task makeRegistry(type: RegisterZenClassesTask) { task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main') dependsOn tasks.compileJava
outputDir = file('build/classes/main') inputDir = file('build/classes/java/main')
outputDir = file('build/classes/java/main')
className = 'minetweaker.mods.ic2.ClassRegistry' className = 'minetweaker.mods.ic2.ClassRegistry'
} }
+3 -21
View File
@@ -1,28 +1,9 @@
import minetweaker.tasks.RegisterZenClassesTask; import minetweaker.tasks.RegisterZenClassesTask;
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
apply plugin: 'forge' apply plugin: 'forge'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft { minecraft {
version = forgeVersion1710 version = forgeVersion1710
@@ -40,8 +21,9 @@ dependencies {
} }
task makeRegistry(type: RegisterZenClassesTask) { task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main') dependsOn tasks.compileJava
outputDir = file('build/classes/main') inputDir = file('build/classes/java/main')
outputDir = file('build/classes/java/main')
className = 'minetweaker.mods.nei.ClassRegistry' className = 'minetweaker.mods.nei.ClassRegistry'
} }
+29 -9
View File
@@ -1,16 +1,41 @@
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
}
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
dependencies {
classpath "com.github.GTNH2:ForgeGradle:FG_1.2-SNAPSHOT"
}
}
apply plugin: 'base' // To add "clean" task to the root project. apply plugin: 'base' // To add "clean" task to the root project.
apply from: 'configuration.gradle' apply from: 'configuration.gradle'
apply plugin: "maven" apply plugin: "maven"
subprojects { subprojects {
apply from: rootProject.file('common.gradle') apply from: rootProject.file('common.gradle')
apply plugin: 'eclipse'
} }
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven { /*maven {
name "Tesla" name "Tesla"
url 'http://maven.epoxide.xyz' url 'http://maven.epoxide.xyz'
} }
@@ -21,7 +46,7 @@ repositories {
maven { maven {
name 'JEI' name 'JEI'
url "http://dvs1.progwml6.com/files/maven" url "http://dvs1.progwml6.com/files/maven"
} } unused */
} }
configurations { configurations {
deployerJars deployerJars
@@ -30,11 +55,6 @@ dependencies {
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.2' deployerJars 'org.apache.maven.wagon:wagon-ftp:2.2'
} }
task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') {
gradleVersion = '3.0'
}
subprojects.each { subproject -> evaluationDependsOn( subproject.path ) } subprojects.each { subproject -> evaluationDependsOn( subproject.path ) }
task setupDecompWorkspaceAll(dependsOn: projects1710.collect { ':' + it + ":setupDecompWorkspace" }) {} task setupDecompWorkspaceAll(dependsOn: projects1710.collect { ':' + it + ":setupDecompWorkspace" }) {}
@@ -37,7 +37,15 @@ public class RegisterZenClassesTask extends DefaultTask {
@OutputDirectory @OutputDirectory
public File outputDir = null; public File outputDir = null;
public void setInputDir(File inputDir) {
this.inputDir = inputDir;
}
public void setOutputDir(File inputDir) {
this.outputDir = inputDir;
}
@Input @Input
public String className; public String className;
+15 -2
View File
@@ -7,13 +7,26 @@ apply from: rootProject.file('configuration.gradle')
// -- end of configurable properties // -- end of configurable properties
repositories { repositories {
mavenLocal()
mavenCentral() mavenCentral()
maven { maven {
name = "forge" name = "forge"
url = "http://files.minecraftforge.net/maven" url = "http://files.minecraftforge.net/maven"
} }
maven { maven {
name = "sonatype" name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/" url = "https://oss.sonatype.org/content/repositories/snapshots/"
} }
} maven {
name = "chickenbones"
url = "http://chickenbones.net/maven/"
}
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ import javax.tools.ToolProvider
// ### Global settings ### // ### Global settings ###
// ####################### // #######################
ext.mineTweakerVersion = "3.2.0-GTNH" ext.mineTweakerVersion = "3.2.3-GTNH"
if (System.getenv('BUILD_NUMBER') != null) if (System.getenv('BUILD_NUMBER') != null)
project.mineTweakerVersion += "."+System.getenv('BUILD_NUMBER') project.mineTweakerVersion += "."+System.getenv('BUILD_NUMBER')
else { else {
+3 -1
View File
@@ -1,2 +1,4 @@
org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
Binary file not shown.
+1 -2
View File
@@ -1,6 +1,5 @@
#Wed Oct 16 21:11:58 CEST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Vendored
+9 -17
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env bash
############################################################################## ##############################################################################
## ##
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
warn () { warn ( ) {
echo "$*" echo "$*"
} }
die () { die ( ) {
echo echo
echo "$*" echo "$*"
echo echo
@@ -154,19 +154,11 @@ if $cygwin ; then
esac esac
fi fi
# Escape application args # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
save () { function splitJvmOpts() {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done JVM_OPTS=("$@")
echo " "
} }
APP_ARGS=$(save "$@") eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# Collect all arguments for the java command, following the shell quoting and substitution rules exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
Vendored
+6
View File
@@ -49,6 +49,7 @@ goto fail
@rem Get command-line arguments, handling Windows variants @rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args :win9xME_args
@rem Slurp the command line arguments. @rem Slurp the command line arguments.
@@ -59,6 +60,11 @@ set _SKIP=2
if "x%~1" == "x" goto execute if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%* set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute :execute
@rem Setup the command line @rem Setup the command line