mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5044de32dd | ||
|
|
7b75ffb679 | ||
|
|
4787672b6e | ||
|
|
22502ff016 | ||
|
|
7c060cb624 | ||
|
|
b6a27cb150 | ||
|
|
6ffcca483f | ||
|
|
dc78b2b39e | ||
|
|
436ad039ca | ||
|
|
a348865dda | ||
|
|
86b4108e4f | ||
|
|
4d4fed2482 | ||
|
|
1796484e7c | ||
|
|
8fff244d95 | ||
|
|
e4a0cc8f35 | ||
|
|
7c0eb67215 | ||
|
|
9167cd1f1d | ||
|
|
11c68ce42a | ||
|
|
94705aeacf | ||
|
|
af79e56481 | ||
|
|
449ce974f4 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
|
||||
# CraftTweaker
|
||||
|
||||
Changelog of CraftTweaker.
|
||||
|
||||
|
||||
@@ -7,12 +7,11 @@ version = ext.mineTweakerVersion
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
dependsOn tasks.compileJava
|
||||
inputDir = file('build/classes/java/main')
|
||||
outputDir = file('build/classes/java/main')
|
||||
className = 'minetweaker.ClassRegistry'
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import minetweaker.api.world.IBiome;
|
||||
import minetweaker.runtime.IScriptProvider;
|
||||
import minetweaker.util.EventList;
|
||||
import minetweaker.util.IEventHandler;
|
||||
import sun.awt.HeadlessToolkit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
@@ -58,8 +57,9 @@ public class MineTweakerImplementationAPI {
|
||||
private static final ListenPlayerLoggedIn LISTEN_LOGIN = new ListenPlayerLoggedIn();
|
||||
private static final ListenPlayerLoggedOut LISTEN_LOGOUT = new ListenPlayerLoggedOut();
|
||||
private static final ListenBlockInfo LISTEN_BLOCK_INFO = new ListenBlockInfo();
|
||||
private static final EventList<ReloadEvent> ONRELOAD = new EventList<ReloadEvent>();
|
||||
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<ReloadEvent>();
|
||||
private static final EventList<ReloadEvent> ONROLLBACK = new EventList<>();
|
||||
private static final EventList<ReloadEvent> ONRELOAD = new EventList<>();
|
||||
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<>();
|
||||
|
||||
static {
|
||||
minetweakerCommands = new HashMap<String, MineTweakerCommand>();
|
||||
@@ -573,6 +573,9 @@ public class MineTweakerImplementationAPI {
|
||||
* @param handler
|
||||
* @return
|
||||
*/
|
||||
public static IEventHandle onRollbackEvent(IEventHandler<ReloadEvent> handler) {
|
||||
return ONROLLBACK.add(handler);
|
||||
}
|
||||
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
|
||||
return ONRELOAD.add(handler);
|
||||
}
|
||||
@@ -621,29 +624,10 @@ public class MineTweakerImplementationAPI {
|
||||
events.onPlayerLoggedIn(LISTEN_LOGIN);
|
||||
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();
|
||||
ONROLLBACK.publish(new ReloadEvent());
|
||||
|
||||
if (MineTweakerAPI.server != null) {
|
||||
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
|
||||
server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() {
|
||||
@@ -707,7 +691,7 @@ public class MineTweakerImplementationAPI {
|
||||
|
||||
private static void copyToClipboard(String value) {
|
||||
StringSelection stringSelection = new StringSelection(value);
|
||||
if (!(Toolkit.getDefaultToolkit() instanceof HeadlessToolkit)) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
int remove(IIngredient output, @Optional boolean nbtMatch);
|
||||
|
||||
|
||||
int remove(IIngredient output);
|
||||
|
||||
/**
|
||||
* Adds a shaped recipe.
|
||||
*
|
||||
@@ -51,7 +53,12 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
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.
|
||||
*
|
||||
@@ -61,7 +68,12 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
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.
|
||||
*
|
||||
@@ -71,7 +83,13 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
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.
|
||||
*
|
||||
@@ -82,7 +100,8 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients);
|
||||
|
||||
|
||||
int removeShaped(IIngredient output);
|
||||
/**
|
||||
* Removes shapeless recipes.
|
||||
*
|
||||
@@ -95,7 +114,13 @@ public interface IRecipeManager {
|
||||
*/
|
||||
@ZenMethod
|
||||
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
|
||||
* crafting recipe exists.
|
||||
|
||||
@@ -28,21 +28,14 @@ public class ShapedRecipe implements ICraftingRecipe {
|
||||
|
||||
public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
|
||||
int numIngredients = 0;
|
||||
for(int i = 0; i < ingredients.length; i++) {
|
||||
IIngredient[] ingredient = ingredients[i];
|
||||
for(int i1 = 0; i1 < ingredient.length; i1++) {
|
||||
if(ingredient[i1] != null) {
|
||||
for (IIngredient[] ingredient : ingredients) {
|
||||
for (IIngredient iIngredient : ingredient) {
|
||||
if (iIngredient != null) {
|
||||
numIngredients++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(IIngredient[] row : ingredients) {
|
||||
// for(IIngredient ingredient : row) {
|
||||
// if(ingredient != null) {
|
||||
// numIngredients++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
this.posx = new byte[numIngredients];
|
||||
this.posy = new byte[numIngredients];
|
||||
this.output = output;
|
||||
|
||||
@@ -52,6 +52,7 @@ public class MTTweaker implements ITweaker {
|
||||
|
||||
Object overrideKey = action.getOverrideKey();
|
||||
if (wereStuck.contains(action)) {
|
||||
MineTweakerAPI.logInfo("WAS STUCK");
|
||||
wereStuck.remove(action);
|
||||
|
||||
if (overrideKey != null) {
|
||||
@@ -76,7 +77,8 @@ public class MTTweaker implements ITweaker {
|
||||
|
||||
@Override
|
||||
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--) {
|
||||
IUndoableAction action = actions.get(i);
|
||||
if (action.canUndo()) {
|
||||
@@ -111,7 +113,7 @@ public class MTTweaker implements ITweaker {
|
||||
System.out.println("Loading scripts");
|
||||
|
||||
scriptData = ScriptProviderMemory.collect(scriptProvider);
|
||||
Set<String> executed = new HashSet<String>();
|
||||
Set<String> executed = new HashSet<>();
|
||||
|
||||
Iterator<IScriptIterator> scripts = scriptProvider.getScripts();
|
||||
while (scripts.hasNext()) {
|
||||
@@ -120,10 +122,10 @@ public class MTTweaker implements ITweaker {
|
||||
if (!executed.contains(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);
|
||||
|
||||
List<ZenParsedFile> files = new ArrayList<ZenParsedFile>();
|
||||
List<ZenParsedFile> files = new ArrayList<>();
|
||||
|
||||
while (script.next()) {
|
||||
Reader reader = null;
|
||||
|
||||
+2
-8
@@ -12,13 +12,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
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.*;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
@@ -74,7 +68,7 @@ public class ScriptProviderMemory implements IScriptProvider {
|
||||
private final Map<String, MemoryModule> modules;
|
||||
|
||||
public ScriptProviderMemory(byte[] scripts) {
|
||||
modules = new HashMap<String, MemoryModule>();
|
||||
modules = new TreeMap<String, MemoryModule>();
|
||||
|
||||
try {
|
||||
InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(scripts));
|
||||
|
||||
@@ -1,29 +1,10 @@
|
||||
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: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
version = "1.7.10-" + ext.mineTweakerVersion
|
||||
archivesBaseName = project.projectDir.name
|
||||
@@ -40,8 +21,9 @@ dependencies {
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
dependsOn tasks.compileJava
|
||||
inputDir = file('build/classes/java/main')
|
||||
outputDir = file('build/classes/java/main')
|
||||
className = 'minetweaker.mc1710.MineTweakerRegistry'
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket;
|
||||
import minetweaker.mc1710.recipes.MCCraftingInventory;
|
||||
import minetweaker.mc1710.recipes.MCRecipeManager;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
@@ -21,7 +22,7 @@ import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
public class FMLEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) {
|
||||
if (ev.player instanceof EntityPlayerMP) {
|
||||
if (ev.player instanceof EntityPlayerMP && MineTweakerConfig.sendLoadScripts) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) ev.player;
|
||||
MineTweakerMod.NETWORK.sendTo(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()), player);
|
||||
}
|
||||
@@ -32,8 +33,8 @@ public class FMLEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent ev) {
|
||||
IPlayer iPlayer = MineTweakerMC.getIPlayer(ev.player);
|
||||
if (MineTweakerMod.INSTANCE.recipes.hasTransformerRecipes()) {
|
||||
MineTweakerMod.INSTANCE.recipes.applyTransformations(MCCraftingInventory.get(ev.craftMatrix, ev.player), iPlayer);
|
||||
if (MCRecipeManager.hasTransformerRecipes()) {
|
||||
MCRecipeManager.applyTransformations(MCCraftingInventory.get(ev.craftMatrix, ev.player), iPlayer);
|
||||
}
|
||||
|
||||
if (MineTweakerImplementationAPI.events.hasPlayerCrafted()) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
package minetweaker.mc1710;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import minetweaker.*;
|
||||
import minetweaker.api.entity.*;
|
||||
import minetweaker.api.formatting.IFormattedText;
|
||||
@@ -15,10 +17,12 @@ import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.tooltip.IngredientTooltips;
|
||||
import minetweaker.mc1710.formatting.IMCFormattedString;
|
||||
import minetweaker.mc1710.item.*;
|
||||
import net.minecraft.client.multiplayer.GuiConnecting;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.item.*;
|
||||
import net.minecraft.entity.player.*;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.event.entity.living.*;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
@@ -42,6 +46,12 @@ public class ForgeEventHandler {
|
||||
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
|
||||
public void onItemTooltip(ItemTooltipEvent ev) {
|
||||
if(ev.itemStack!= null) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class MCPlatformFunctions implements IPlatformFunctions {
|
||||
|
||||
@Override
|
||||
public void distributeScripts(byte[] data) {
|
||||
MineTweakerMod.NETWORK.sendToAll(new MineTweakerLoadScriptsPacket(data));
|
||||
if (MineTweakerConfig.sendScriptsOnReloading) MineTweakerMod.NETWORK.sendToAll(new MineTweakerLoadScriptsPacket(data));
|
||||
}
|
||||
|
||||
@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.ScriptProviderCustom;
|
||||
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.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Main mod class. Performs some general logic, initialization of the API and
|
||||
@@ -77,20 +81,22 @@ public class MineTweakerMod {
|
||||
@Mod.Instance(MODID)
|
||||
public static MineTweakerMod INSTANCE;
|
||||
|
||||
public final MCRecipeManager recipes;
|
||||
private final IScriptProvider scriptsGlobal;
|
||||
private final ScriptProviderCustom scriptsIMC;
|
||||
private volatile boolean loaded = false;
|
||||
|
||||
public MineTweakerMod() {
|
||||
MCRecipeManager.recipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList();
|
||||
MineTweakerImplementationAPI.init(
|
||||
new MCOreDict(),
|
||||
recipes = new MCRecipeManager(),
|
||||
new MCRecipeManager(),
|
||||
new MCFurnaceManager(),
|
||||
MCGame.INSTANCE,
|
||||
new MCLoadedMods(),
|
||||
new MCFormatter(),
|
||||
new MCVanilla());
|
||||
|
||||
|
||||
MineTweakerImplementationAPI.logger.addLogger(new FileLogger(new File("minetweaker.log")));
|
||||
MineTweakerImplementationAPI.platform = MCPlatformFunctions.INSTANCE;
|
||||
|
||||
@@ -123,6 +129,8 @@ public class MineTweakerMod {
|
||||
|
||||
@EventHandler
|
||||
public void onLoad(FMLPreInitializationEvent ev) {
|
||||
MineTweakerConfig.file = new File(ev.getModConfigurationDirectory(), MODID + ".cfg");
|
||||
MineTweakerConfig.load();
|
||||
MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());
|
||||
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
|
||||
}
|
||||
@@ -144,17 +152,13 @@ public class MineTweakerMod {
|
||||
ItemBracketHandler.rebuildItemRegistry();
|
||||
LiquidBracketHandler.rebuildLiquidRegistry();
|
||||
MineTweakerAPI.logInfo("MineTweaker: Sucessfully built item registry");
|
||||
if (MineTweakerPlatformUtils.isClient()) {
|
||||
MineTweakerAPI.client = new MCClient();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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");
|
||||
if (!scriptsDir.exists()) {
|
||||
scriptsDir.mkdir();
|
||||
@@ -164,12 +168,21 @@ public class MineTweakerMod {
|
||||
IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal,scriptsLocal);
|
||||
|
||||
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 onServerStarting(FMLServerStartingEvent ev) {
|
||||
|
||||
public void onClientAboutToConnect() {
|
||||
if (!MineTweakerConfig.loadScriptsBeforeConnection) return;
|
||||
IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal);
|
||||
MineTweakerImplementationAPI.setScriptProvider(cascaded);
|
||||
if (loaded && MineTweakerConfig.antiStuck) return;
|
||||
MineTweakerImplementationAPI.reload();
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MCItemStack implements IItemStack {
|
||||
throw new IllegalArgumentException("stack cannot be null");
|
||||
|
||||
stack = itemStack.copy();
|
||||
items = Collections.<IItemStack>singletonList(this);
|
||||
items = Collections.singletonList(this);
|
||||
}
|
||||
|
||||
public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
|
||||
@@ -67,13 +67,13 @@ public class MCItemStack implements IItemStack {
|
||||
throw new IllegalArgumentException("stack cannot be null");
|
||||
|
||||
stack = itemStack;
|
||||
items = Collections.<IItemStack>singletonList(this);
|
||||
items = Collections.singletonList(this);
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
|
||||
stack = itemStack;
|
||||
items = Collections.<IItemStack>singletonList(this);
|
||||
items = Collections.singletonList(this);
|
||||
this.tag = tag;
|
||||
this.wildcardSize = wildcardSize;
|
||||
}
|
||||
|
||||
+3
-1
@@ -9,6 +9,8 @@ package minetweaker.mc1710.network;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import minetweaker.mc1710.MineTweakerConfig;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
@@ -21,7 +23,7 @@ import java.awt.datatransfer.StringSelection;
|
||||
public class MineTweakerCopyClipboardHandler implements IMessageHandler<MineTweakerCopyClipboardPacket, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(MineTweakerCopyClipboardPacket message, MessageContext ctx) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
if (Desktop.isDesktopSupported() && MineTweakerConfig.handleDesktopPackets) {
|
||||
StringSelection stringSelection = new StringSelection(message.getData());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
|
||||
+2
-5
@@ -11,7 +11,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.mc1710.client.MCClient;
|
||||
import minetweaker.mc1710.MineTweakerConfig;
|
||||
import minetweaker.runtime.providers.ScriptProviderMemory;
|
||||
|
||||
/**
|
||||
@@ -21,13 +21,10 @@ import minetweaker.runtime.providers.ScriptProviderMemory;
|
||||
public class MineTweakerLoadScriptsHandler implements IMessageHandler<MineTweakerLoadScriptsPacket, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(MineTweakerLoadScriptsPacket message, MessageContext ctx) {
|
||||
if (MineTweakerAPI.server == null) {
|
||||
MineTweakerAPI.client = new MCClient();
|
||||
|
||||
if (MineTweakerAPI.server == null && MineTweakerConfig.handleLoadScripts) {
|
||||
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderMemory(message.getData()));
|
||||
MineTweakerImplementationAPI.reload();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -9,6 +9,8 @@ package minetweaker.mc1710.network;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import minetweaker.mc1710.MineTweakerConfig;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -21,15 +23,13 @@ import java.net.URISyntaxException;
|
||||
public class MineTweakerOpenBrowserHandler implements IMessageHandler<MineTweakerOpenBrowserPacket, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(MineTweakerOpenBrowserPacket message, MessageContext ctx) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
if (Desktop.isDesktopSupported() && MineTweakerConfig.handleDesktopPackets) {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
try {
|
||||
desktop.browse(new URI(message.getUrl()));
|
||||
} catch (IOException e) {
|
||||
} catch (URISyntaxException e) {
|
||||
}
|
||||
} else {
|
||||
System.out.println("Desktop not supported");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -12,6 +12,7 @@ import minetweaker.api.data.IData;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.mc1710.MineTweakerConfig;
|
||||
import minetweaker.mc1710.MineTweakerMod;
|
||||
import minetweaker.mc1710.data.NBTConverter;
|
||||
import minetweaker.mc1710.network.MineTweakerCopyClipboardPacket;
|
||||
@@ -126,7 +127,7 @@ public class MCPlayer implements IPlayer {
|
||||
|
||||
@Override
|
||||
public void openBrowser(String url) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
if (player instanceof EntityPlayerMP && MineTweakerConfig.handleDesktopPackets) {
|
||||
MineTweakerMod.NETWORK.sendTo(
|
||||
new MineTweakerOpenBrowserPacket(url),
|
||||
(EntityPlayerMP) player);
|
||||
@@ -135,7 +136,7 @@ public class MCPlayer implements IPlayer {
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String value) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
if (player instanceof EntityPlayerMP && MineTweakerConfig.handleDesktopPackets) {
|
||||
MineTweakerMod.NETWORK.sendTo(
|
||||
new MineTweakerCopyClipboardPacket(value),
|
||||
(EntityPlayerMP) player);
|
||||
|
||||
+535
-292
@@ -2,12 +2,21 @@ package minetweaker.mc1710.recipes;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
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.util.IEventHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
@@ -18,30 +27,42 @@ import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
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
|
||||
*/
|
||||
public class MCRecipeManager implements IRecipeManager {
|
||||
private final List<IRecipe> recipes;
|
||||
private final List<ICraftingRecipe> transformerRecipes;
|
||||
public final class MCRecipeManager implements IRecipeManager {
|
||||
public static final List<ActionBaseAddRecipe> recipesToAdd = new ArrayList<>();
|
||||
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() {
|
||||
recipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList();
|
||||
transformerRecipes = new ArrayList<ICraftingRecipe>();
|
||||
MineTweakerImplementationAPI.onPostReload(new HandleLateAdditionsAndRemovals());
|
||||
MineTweakerImplementationAPI.onRollbackEvent(new HandleLateAdditionsAndRemovals());
|
||||
}
|
||||
|
||||
public boolean hasTransformerRecipes() {
|
||||
public static boolean hasTransformerRecipes() {
|
||||
return transformerRecipes.size() > 0;
|
||||
}
|
||||
|
||||
public void applyTransformations(ICraftingInventory inventory, IPlayer byPlayer) {
|
||||
public static void applyTransformations(ICraftingInventory inventory, IPlayer byPlayer) {
|
||||
for (ICraftingRecipe recipe : transformerRecipes) {
|
||||
if (recipe.matches(inventory)) {
|
||||
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
|
||||
public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient) {
|
||||
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>();
|
||||
List<ICraftingRecipe> results = new ArrayList<>();
|
||||
|
||||
for (IRecipe recipe : recipes) {
|
||||
if (ingredient.matches(MineTweakerMC.getIItemStack(recipe.getRecipeOutput()))) {
|
||||
@@ -65,203 +112,129 @@ public class MCRecipeManager implements IRecipeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ICraftingRecipe> getAll() {
|
||||
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>();
|
||||
|
||||
for (IRecipe recipe : recipes) {
|
||||
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
|
||||
results.add(converted);
|
||||
}
|
||||
|
||||
return results;
|
||||
public int remove(IIngredient output) {
|
||||
return remove(output, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(IIngredient output, @Optional boolean nbtMatch) {
|
||||
List<IRecipe> toRemove = new ArrayList<IRecipe>();
|
||||
List<Integer> removeIndex = new ArrayList<Integer>();
|
||||
for (int i = 0; i < recipes.size(); i++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if(output == null) {
|
||||
MineTweakerAPI.logError("Cannot remove recipes for a null item!");
|
||||
return 0;
|
||||
}
|
||||
actionRemoveRecipesNoIngredients.addOutput(output, nbtMatch);
|
||||
return 1;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
|
||||
return toRemove.size();
|
||||
@Override
|
||||
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
|
||||
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
|
||||
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
|
||||
public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) {
|
||||
ShapelessRecipe recipe = new ShapelessRecipe(output, ingredients, function, action);
|
||||
IRecipe irecipe = RecipeConverter.convert(recipe);
|
||||
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
|
||||
if(checkShapelessNulls(output, ingredients))
|
||||
return;
|
||||
|
||||
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
|
||||
public int removeShaped(IIngredient output, IIngredient[][] ingredients) {
|
||||
int ingredientsWidth = 0;
|
||||
int ingredientsHeight = 0;
|
||||
|
||||
if (ingredients != null) {
|
||||
ingredientsHeight = ingredients.length;
|
||||
|
||||
for (int i = 0; i < ingredients.length; i++) {
|
||||
ingredientsWidth = Math.max(ingredientsWidth, ingredients[i].length);
|
||||
}
|
||||
if(output == null) {
|
||||
MineTweakerAPI.logError("Cannot remove recipes for a null item!");
|
||||
return 0;
|
||||
}
|
||||
recipesToRemove.add(new ActionRemoveShapedRecipes(output, ingredients));
|
||||
return 1;
|
||||
}
|
||||
|
||||
List<IRecipe> toRemove = new ArrayList<IRecipe>();
|
||||
List<Integer> removeIndex = new ArrayList<Integer>();
|
||||
outer:
|
||||
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
|
||||
public int removeShaped(IIngredient output) {
|
||||
return removeShaped(output, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeShapeless(IIngredient output, IIngredient[] ingredients, boolean wildcard) {
|
||||
List<IRecipe> toRemove = new ArrayList<IRecipe>();
|
||||
List<Integer> removeIndex = new ArrayList<Integer>();
|
||||
outer:
|
||||
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);
|
||||
if(output == null) {
|
||||
MineTweakerAPI.logError("Cannot remove recipes for a null item!");
|
||||
return 0;
|
||||
}
|
||||
recipesToRemove.add(new ActionRemoveShapelessRecipes(output, ingredients, wildcard));
|
||||
return 1;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
|
||||
return toRemove.size();
|
||||
@Override
|
||||
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
|
||||
@@ -294,6 +267,390 @@ public class MCRecipeManager implements IRecipeManager {
|
||||
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 {
|
||||
@Override
|
||||
@@ -301,119 +658,5 @@ public class MCRecipeManager implements IRecipeManager {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+7
-1
@@ -53,7 +53,13 @@ public class RecipeConverter {
|
||||
}
|
||||
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) {
|
||||
IIngredient[] ingredients = recipe.getIngredients();
|
||||
int type = getRecipeType(ingredients);
|
||||
|
||||
@@ -1,28 +1,9 @@
|
||||
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'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = forgeVersion1710
|
||||
@@ -39,8 +20,9 @@ dependencies {
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
dependsOn tasks.compileJava
|
||||
inputDir = file('build/classes/java/main')
|
||||
outputDir = file('build/classes/java/main')
|
||||
className = 'minetweaker.mods.ic2.ClassRegistry'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,9 @@
|
||||
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'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = forgeVersion1710
|
||||
@@ -40,8 +21,9 @@ dependencies {
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
dependsOn tasks.compileJava
|
||||
inputDir = file('build/classes/java/main')
|
||||
outputDir = file('build/classes/java/main')
|
||||
className = 'minetweaker.mods.nei.ClassRegistry'
|
||||
}
|
||||
|
||||
|
||||
+29
-9
@@ -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 from: 'configuration.gradle'
|
||||
apply plugin: "maven"
|
||||
|
||||
|
||||
|
||||
subprojects {
|
||||
apply from: rootProject.file('common.gradle')
|
||||
apply plugin: 'eclipse'
|
||||
}
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
/*maven {
|
||||
name "Tesla"
|
||||
url 'http://maven.epoxide.xyz'
|
||||
}
|
||||
@@ -21,7 +46,7 @@ repositories {
|
||||
maven {
|
||||
name 'JEI'
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
} unused */
|
||||
}
|
||||
configurations {
|
||||
deployerJars
|
||||
@@ -30,11 +55,6 @@ dependencies {
|
||||
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 ) }
|
||||
|
||||
task setupDecompWorkspaceAll(dependsOn: projects1710.collect { ':' + it + ":setupDecompWorkspace" }) {}
|
||||
|
||||
@@ -37,7 +37,15 @@ public class RegisterZenClassesTask extends DefaultTask {
|
||||
|
||||
@OutputDirectory
|
||||
public File outputDir = null;
|
||||
|
||||
|
||||
public void setInputDir(File inputDir) {
|
||||
this.inputDir = inputDir;
|
||||
}
|
||||
|
||||
public void setOutputDir(File inputDir) {
|
||||
this.outputDir = inputDir;
|
||||
}
|
||||
|
||||
@Input
|
||||
public String className;
|
||||
|
||||
|
||||
+15
-2
@@ -7,13 +7,26 @@ apply from: rootProject.file('configuration.gradle')
|
||||
// -- end of configurable properties
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
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"
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import javax.tools.ToolProvider
|
||||
// ### Global settings ###
|
||||
// #######################
|
||||
|
||||
ext.mineTweakerVersion = "3.2.0-GTNH"
|
||||
ext.mineTweakerVersion = "3.2.3-GTNH"
|
||||
if (System.getenv('BUILD_NUMBER') != null)
|
||||
project.mineTweakerVersion += "."+System.getenv('BUILD_NUMBER')
|
||||
else {
|
||||
|
||||
+3
-1
@@ -1,2 +1,4 @@
|
||||
org.gradle.daemon=false
|
||||
org.gradle.parallel=true
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
|
||||
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
|
||||
Vendored
BIN
Binary file not shown.
+1
-2
@@ -1,6 +1,5 @@
|
||||
#Wed Oct 16 21:11:58 CEST 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
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
|
||||
@@ -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.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
@@ -154,19 +154,11 @@ if $cygwin ; then
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
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
|
||||
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" "$@"
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
Vendored
+6
@@ -49,6 +49,7 @@ goto fail
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
@@ -59,6 +60,11 @@ set _SKIP=2
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
Reference in new issue
Block a user