1.10.2 - broken
This commit is contained in:
parent
6ee996fb5c
commit
90925311ba
91 changed files with 3416 additions and 3022 deletions
21
build.gradle
21
build.gradle
|
@ -1,3 +1,5 @@
|
||||||
|
import groovy.io.FileType
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
@ -7,7 +9,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,20 +27,25 @@ group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventi
|
||||||
archivesBaseName = "ModTweaker2"
|
archivesBaseName = "ModTweaker2"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "${config.minecraft.version}-${config.forge.version}"
|
version = "${config.forge.version}"
|
||||||
runDir = "eclipse"
|
runDir = "eclipse"
|
||||||
replace "@modVersion@", config.mod.version
|
replace "@modVersion@", config.mod.version
|
||||||
mappings = "stable_20"
|
mappings = "snapshot_20160518"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
|
||||||
name = "forestry"
|
}
|
||||||
url = "http://maven.ic2.player.to/"
|
dependencies {
|
||||||
|
def list = []
|
||||||
|
|
||||||
|
def dir = new File("libs/")
|
||||||
|
dir.eachFileRecurse (FileType.FILES) { file ->
|
||||||
|
list << file
|
||||||
|
// deobfCompile file.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
processResources
|
processResources
|
||||||
{
|
{
|
||||||
inputs.property "version", project.version
|
inputs.property "version", project.version
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
minecraft.version=1.8.9
|
minecraft.version=1.10.2
|
||||||
forge.version=11.15.0.1701
|
forge.version=1.10.2-12.18.0.2005-1.10.0
|
||||||
|
|
||||||
mod.version=1.0.0
|
mod.version=2.0.0
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/Mantle-1.9.4-0.10.1.jenkins142.jar
Normal file
BIN
libs/Mantle-1.9.4-0.10.1.jenkins142.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
libs/TConstruct-1.9.4-2.3.1.jenkins229.jar
Normal file
BIN
libs/TConstruct-1.9.4-2.3.1.jenkins229.jar
Normal file
Binary file not shown.
BIN
libs/forestry_1.9.4-5.0.13.158.jar
Normal file
BIN
libs/forestry_1.9.4-5.0.13.158.jar
Normal file
Binary file not shown.
|
@ -1,7 +1,5 @@
|
||||||
package modtweaker2;
|
package modtweaker2;
|
||||||
|
|
||||||
import static modtweaker2.helpers.LogHelper.print;
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -10,6 +8,8 @@ import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.LogHelper.print;
|
||||||
|
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
public static int cooldown;
|
public static int cooldown;
|
||||||
public static boolean active;
|
public static boolean active;
|
||||||
|
@ -17,14 +17,14 @@ public class ClientEvents {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onDrawTooltip(ItemTooltipEvent event) {
|
public void onDrawTooltip(ItemTooltipEvent event) {
|
||||||
|
|
||||||
IPlayer player = MineTweakerMC.getIPlayer(event.entityPlayer);
|
IPlayer player = MineTweakerMC.getIPlayer(event.getEntityPlayer());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
IItemStack hand = MineTweakerMC.getIItemStack(event.itemStack);
|
IItemStack hand = MineTweakerMC.getIItemStack(event.getItemStack());
|
||||||
if (hand != null) {
|
if (hand != null) {
|
||||||
if (active) {
|
if (active) {
|
||||||
|
|
||||||
String print = hand.toString();
|
String print = hand.toString();
|
||||||
event.toolTip.add(print);
|
event.getToolTip().add(print);
|
||||||
if (GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) {
|
if (GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) {
|
||||||
if (cooldown <= 0) {
|
if (cooldown <= 0) {
|
||||||
cooldown = 30;
|
cooldown = 30;
|
||||||
|
|
|
@ -4,9 +4,6 @@ import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.api.server.ICommandFunction;
|
import minetweaker.api.server.ICommandFunction;
|
||||||
import modtweaker2.commands.EntityMappingLogger;
|
import modtweaker2.commands.EntityMappingLogger;
|
||||||
import modtweaker2.mods.thaumcraft.commands.AspectLogger;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.commands.ResearchLogger;
|
|
||||||
import modtweaker2.utils.TweakerPlugin;
|
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
|
|
||||||
|
@ -23,10 +20,6 @@ public class Commands {
|
||||||
MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger());
|
MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger());
|
||||||
|
|
||||||
|
|
||||||
if (TweakerPlugin.isLoaded("Thaumcraft")) {
|
|
||||||
MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger());
|
|
||||||
MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,5 @@ public class ModProps {
|
||||||
public static final String NAME = "Mod Tweaker 2", name = NAME;
|
public static final String NAME = "Mod Tweaker 2", name = NAME;
|
||||||
public static final String MODID = "modtweaker2", modid = MODID;
|
public static final String MODID = "modtweaker2", modid = MODID;
|
||||||
public static final String VERSION = "@modVersion@", version = VERSION;
|
public static final String VERSION = "@modVersion@", version = VERSION;
|
||||||
public static final String DEPENDENCIES = "required-after:crafttweaker;", dependencies = DEPENDENCIES;
|
public static final String DEPENDENCIES = "required-after:MineTweaker3;", dependencies = DEPENDENCIES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
package modtweaker2;
|
package modtweaker2;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
import minetweaker.MineTweakerImplementationAPI;
|
||||||
import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
|
import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
|
||||||
import minetweaker.runtime.providers.ScriptProviderDirectory;
|
import minetweaker.runtime.providers.ScriptProviderDirectory;
|
||||||
import minetweaker.util.IEventHandler;
|
import minetweaker.util.IEventHandler;
|
||||||
import modtweaker2.mods.thaumcraft.Thaumcraft;
|
import modtweaker2.mods.forestry.Forestry;
|
||||||
|
import modtweaker2.mods.tconstruct.TConstruct;
|
||||||
import modtweaker2.proxy.CommonProxy;
|
import modtweaker2.proxy.CommonProxy;
|
||||||
import modtweaker2.utils.TweakerPlugin;
|
import modtweaker2.utils.TweakerPlugin;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
@ -23,6 +19,10 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
@Mod(modid = ModProps.modid, version = ModProps.version, dependencies = ModProps.dependencies)
|
@Mod(modid = ModProps.modid, version = ModProps.version, dependencies = ModProps.dependencies)
|
||||||
public class ModTweaker2 {
|
public class ModTweaker2 {
|
||||||
|
@ -44,7 +44,8 @@ public class ModTweaker2 {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
logger.info("Starting Initialization for " + ModProps.modid);
|
logger.info("Starting Initialization for " + ModProps.modid);
|
||||||
TweakerPlugin.register("Thaumcraft", Thaumcraft.class);
|
TweakerPlugin.register("forestry", Forestry.class);
|
||||||
|
TweakerPlugin.register("tconstruct", TConstruct.class);
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
||||||
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package modtweaker2.mods.thaumcraft.aspect;
|
package modtweaker2.brackets;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.IBracketHandler;
|
import minetweaker.IBracketHandler;
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.annotations.BracketHandler;
|
import minetweaker.annotations.BracketHandler;
|
||||||
import minetweaker.api.item.IngredientAny;
|
import minetweaker.api.item.IngredientAny;
|
||||||
|
import modtweaker2.brackets.util.IMaterial;
|
||||||
|
import modtweaker2.brackets.util.MCMaterial;
|
||||||
|
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
||||||
import stanhebben.zenscript.expression.ExpressionCallStatic;
|
import stanhebben.zenscript.expression.ExpressionCallStatic;
|
||||||
import stanhebben.zenscript.expression.ExpressionString;
|
import stanhebben.zenscript.expression.ExpressionString;
|
||||||
|
@ -14,36 +15,37 @@ import stanhebben.zenscript.parser.Token;
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
import stanhebben.zenscript.type.natives.IJavaMethod;
|
||||||
import stanhebben.zenscript.util.ZenPosition;
|
import stanhebben.zenscript.util.ZenPosition;
|
||||||
import thaumcraft.api.aspects.Aspect;
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
@BracketHandler(priority = 100)
|
@BracketHandler(priority = 100)
|
||||||
public class AspectBracketHandler implements IBracketHandler {
|
public class MaterialBracketHandler implements IBracketHandler {
|
||||||
|
|
||||||
|
public static IMaterial getMaterial(String name) {
|
||||||
|
return new MCMaterial(TinkerRegistry.getMaterial(name));
|
||||||
|
}
|
||||||
|
|
||||||
private final IZenSymbol symbolAny;
|
private final IZenSymbol symbolAny;
|
||||||
private final IJavaMethod method;
|
private final IJavaMethod method;
|
||||||
|
|
||||||
public AspectBracketHandler() {
|
public MaterialBracketHandler() {
|
||||||
this.symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
|
|
||||||
this.method = MineTweakerAPI.getJavaMethod(AspectBracketHandler.class, "getAspect", String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IAspectStack getAspect(String name) {
|
symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
|
||||||
Aspect aspect = Aspect.getAspect(name.toLowerCase());
|
method = MineTweakerAPI.getJavaMethod(MaterialBracketHandler.class, "getMaterial", String.class);
|
||||||
if (aspect != null) {
|
|
||||||
return new MCAspectStack(new AspectStack(aspect, 1));
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
||||||
|
// any symbol
|
||||||
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
|
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
|
||||||
return symbolAny;
|
return symbolAny;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokens.size() > 2) {
|
if (tokens.size() > 2) {
|
||||||
if (tokens.get(0).getValue().equals("aspect") && tokens.get(1).getValue().equals(":")) {
|
if (tokens.get(0).getValue().equals("material") && tokens.get(1).getValue().equals(":")) {
|
||||||
return find(environment, tokens, 2, tokens.size());
|
return find(environment, tokens, 2, tokens.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,27 +54,26 @@ public class AspectBracketHandler implements IBracketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
||||||
StringBuilder value = new StringBuilder();
|
StringBuilder valueBuilder = new StringBuilder();
|
||||||
|
|
||||||
for (int i = startIndex; i < endIndex; i++) {
|
for (int i = startIndex; i < endIndex; i++) {
|
||||||
Token token = tokens.get(i);
|
Token token = tokens.get(i);
|
||||||
value.append(token.getValue());
|
valueBuilder.append(token.getValue());
|
||||||
}
|
}
|
||||||
|
IMaterial material = getMaterial(valueBuilder.toString());
|
||||||
Aspect aspect = Aspect.getAspect(value.toString().toLowerCase());
|
if (!material.getName().equals("unknown")) {
|
||||||
|
MineTweakerAPI.logInfo("Material wasn't null");
|
||||||
if(aspect != null) {
|
return new MaterialReferenceSymbol(environment, valueBuilder.toString());
|
||||||
return new AspectReferenceSymbol(environment, value.toString());
|
|
||||||
}
|
}
|
||||||
|
MineTweakerAPI.logInfo("Material was null");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AspectReferenceSymbol implements IZenSymbol {
|
private class MaterialReferenceSymbol implements IZenSymbol {
|
||||||
private final IEnvironmentGlobal environment;
|
private final IEnvironmentGlobal environment;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
public AspectReferenceSymbol(IEnvironmentGlobal environment, String name) {
|
public MaterialReferenceSymbol(IEnvironmentGlobal environment, String name) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
68
src/main/java/modtweaker2/brackets/util/IMaterial.java
Normal file
68
src/main/java/modtweaker2/brackets/util/IMaterial.java
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
package modtweaker2.brackets.util;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenGetter;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
import stanhebben.zenscript.annotations.ZenSetter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
@ZenClass("modtweaker.materials.IMaterial")
|
||||||
|
public interface IMaterial {
|
||||||
|
|
||||||
|
@ZenGetter
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
boolean matches(IMaterial var1);
|
||||||
|
|
||||||
|
Object getInternal();
|
||||||
|
|
||||||
|
@ZenGetter("definition")
|
||||||
|
IMaterialDefinition getDefinition();
|
||||||
|
|
||||||
|
@ZenSetter("durabilityHead")
|
||||||
|
void setDurabilityHead(int durability);
|
||||||
|
|
||||||
|
@ZenGetter("durabilityHead")
|
||||||
|
int getDurabilityHead();
|
||||||
|
|
||||||
|
@ZenSetter("miningSpeedHead")
|
||||||
|
void setMiningSpeedHead(float miningSpeed);
|
||||||
|
|
||||||
|
@ZenGetter("miningSpeedHead")
|
||||||
|
float getMiningSpeedHead();
|
||||||
|
|
||||||
|
@ZenSetter("attackHead")
|
||||||
|
void setAttackHead(float attack);
|
||||||
|
|
||||||
|
@ZenGetter("attackHead")
|
||||||
|
float getAttackHead();
|
||||||
|
|
||||||
|
@ZenSetter("harvestLevelHead")
|
||||||
|
void setHarvestLevelHead(int level);
|
||||||
|
|
||||||
|
@ZenGetter("harvestLevelHead")
|
||||||
|
int getHarvestLevelHead();
|
||||||
|
|
||||||
|
|
||||||
|
@ZenSetter("durabilityHandle")
|
||||||
|
void setDurabilityHandle(int durability);
|
||||||
|
|
||||||
|
@ZenGetter("durabilityHandle")
|
||||||
|
int getDurabilityHandle();
|
||||||
|
|
||||||
|
@ZenSetter("modifierHandle")
|
||||||
|
void setModifierHandle(float modifier);
|
||||||
|
|
||||||
|
@ZenGetter("modifierHandle")
|
||||||
|
float getModifierHandle();
|
||||||
|
|
||||||
|
@ZenSetter("durabilityExtra")
|
||||||
|
void setDurabilityExtra(int durability);
|
||||||
|
|
||||||
|
@ZenGetter("durabilityExtra")
|
||||||
|
int getDurabilityExtra();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package modtweaker2.brackets.util;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
@ZenClass("modtweaker.material.IMaterialDefinition")
|
||||||
|
public interface IMaterialDefinition {
|
||||||
|
|
||||||
|
@ZenOperator(OperatorType.MUL)
|
||||||
|
public IMaterial asMaterial();
|
||||||
|
|
||||||
|
@ZenGetter("name")
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
@ZenGetter("displayName")
|
||||||
|
public String getDisplayName();
|
||||||
|
|
||||||
|
}
|
111
src/main/java/modtweaker2/brackets/util/MCMaterial.java
Normal file
111
src/main/java/modtweaker2/brackets/util/MCMaterial.java
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
package modtweaker2.brackets.util;
|
||||||
|
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import modtweaker2.mods.tconstruct.actions.*;
|
||||||
|
import slimeknights.tconstruct.library.materials.HandleMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.HeadMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
public class MCMaterial implements IMaterial {
|
||||||
|
private final Material material;
|
||||||
|
|
||||||
|
public MCMaterial(Material material) {
|
||||||
|
this.material = material;
|
||||||
|
System.out.println("added: " + material.getIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return material.getIdentifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(IMaterial var1) {
|
||||||
|
return var1.getName().equals(getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getInternal() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMaterialDefinition getDefinition() {
|
||||||
|
return new MCMaterialDefinition(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDurabilityHead(int durability) {
|
||||||
|
MineTweakerAPI.apply(new SetDurabilityAction(this, "head", durability));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDurabilityHead() {
|
||||||
|
return ((HeadMaterialStats) material.getStats("head")).durability;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMiningSpeedHead(float miningSpeed) {
|
||||||
|
MineTweakerAPI.apply(new SetMiningSpeedAction(this, "head", miningSpeed));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getMiningSpeedHead() {
|
||||||
|
return ((HeadMaterialStats) material.getStats("head")).miningspeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttackHead(float attack) {
|
||||||
|
MineTweakerAPI.apply(new SetAttackAction(this, "head", attack));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getAttackHead() {
|
||||||
|
return ((HeadMaterialStats) material.getStats("head")).attack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHarvestLevelHead(int level) {
|
||||||
|
MineTweakerAPI.apply(new SetHarvestLevelAction(this, "head", level));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHarvestLevelHead() {
|
||||||
|
return ((HeadMaterialStats) material.getStats("head")).harvestLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDurabilityHandle(int durability) {
|
||||||
|
MineTweakerAPI.apply(new SetDurabilityAction(this, "handle", durability));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDurabilityHandle() {
|
||||||
|
return ((HandleMaterialStats) material.getStats("handle")).durability;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setModifierHandle(float modifier) {
|
||||||
|
MineTweakerAPI.apply(new SetModifierAction(this, "handle", modifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getModifierHandle() {
|
||||||
|
return ((HandleMaterialStats) material.getStats("handle")).modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDurabilityExtra(int durability) {
|
||||||
|
MineTweakerAPI.apply(new SetDurabilityAction(this, "extra", durability));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDurabilityExtra() {
|
||||||
|
return ((HandleMaterialStats) material.getStats("extra")).durability;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package modtweaker2.brackets.util;
|
||||||
|
|
||||||
|
import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MCMaterialDefinition implements IMaterialDefinition {
|
||||||
|
private final Material material;
|
||||||
|
|
||||||
|
public MCMaterialDefinition(Material material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMaterial asMaterial() {
|
||||||
|
return new MCMaterial(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return material.getLocalizedName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return material.getLocalizedName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
package modtweaker2.commands;
|
package modtweaker2.commands;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
import minetweaker.MineTweakerImplementationAPI;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
|
@ -9,13 +7,15 @@ import minetweaker.api.server.ICommandFunction;
|
||||||
import modtweaker2.ModTweaker2;
|
import modtweaker2.ModTweaker2;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class EntityMappingLogger implements ICommandFunction {
|
public class EntityMappingLogger implements ICommandFunction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Set<String> keys = EntityList.stringToClassMapping.keySet();
|
Set<String> keys = EntityList.NAME_TO_CLASS.keySet();
|
||||||
|
|
||||||
System.out.println("Mob Keys: " + keys.size());
|
System.out.println("Mob Keys: " + keys.size());
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,27 @@
|
||||||
package modtweaker2.helpers;
|
package modtweaker2.helpers;
|
||||||
|
|
||||||
import static modtweaker2.helpers.ReflectionHelper.getConstructor;
|
|
||||||
import static modtweaker2.helpers.ReflectionHelper.getFinalObject;
|
|
||||||
import static modtweaker2.helpers.ReflectionHelper.getInstance;
|
|
||||||
import static modtweaker2.helpers.ReflectionHelper.getStaticObject;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
import net.minecraftforge.common.ChestGenHooks;
|
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.ReflectionHelper.*;
|
||||||
|
|
||||||
public class ForgeHelper {
|
public class ForgeHelper {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static Map translate = null;
|
public static Map translate = null;
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static List seeds = null;
|
public static List seeds = null;
|
||||||
public static HashMap<String, ChestGenHooks> loot = null;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
seeds = getStaticObject(ForgeHooks.class, "seedList");
|
seeds = getStaticObject(ForgeHooks.class, "seedList");
|
||||||
loot = getStaticObject(ChestGenHooks.class, "chestInfo");
|
translate = getFinalObject(getStaticObject(I18n.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c");
|
||||||
translate = getFinalObject(getStaticObject(StatCollector.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
package modtweaker2.helpers;
|
package modtweaker2.helpers;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import minetweaker.api.entity.IEntity;
|
import minetweaker.api.entity.IEntity;
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import minetweaker.mc18.item.MCItemStack;
|
import minetweaker.mc19.item.MCItemStack;
|
||||||
import minetweaker.mc18.liquid.MCLiquidStack;
|
import minetweaker.mc19.liquid.MCLiquidStack;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -17,6 +14,9 @@ import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class InputHelper {
|
public class InputHelper {
|
||||||
public static boolean isABlock(IItemStack block) {
|
public static boolean isABlock(IItemStack block) {
|
||||||
if (!(isABlock(toStack(block)))) {
|
if (!(isABlock(toStack(block)))) {
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
package modtweaker2.helpers;
|
package modtweaker2.helpers;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
import minetweaker.MineTweakerImplementationAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.mc18.item.MCItemStack;
|
import minetweaker.mc19.item.MCItemStack;
|
||||||
import modtweaker2.mods.thaumcraft.aspect.AspectStack;
|
|
||||||
import modtweaker2.mods.thaumcraft.aspect.MCAspectStack;
|
|
||||||
import modtweaker2.utils.TweakerPlugin;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
|
@ -22,8 +15,9 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||||
import thaumcraft.api.aspects.Aspect;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LogHelper {
|
public class LogHelper {
|
||||||
public static void logPrinted(IPlayer player) {
|
public static void logPrinted(IPlayer player) {
|
||||||
|
@ -64,35 +58,27 @@ public class LogHelper {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static String getStackDescription(Object object) {
|
public static String getStackDescription(Object object) {
|
||||||
if(object instanceof IIngredient) {
|
if (object instanceof IIngredient) {
|
||||||
return getStackDescription((IIngredient)object);
|
return getStackDescription((IIngredient) object);
|
||||||
} else if (object instanceof ItemStack) {
|
} else if (object instanceof ItemStack) {
|
||||||
return new MCItemStack((ItemStack)object).toString();
|
return new MCItemStack((ItemStack) object).toString();
|
||||||
} else if (object instanceof FluidStack) {
|
} else if (object instanceof FluidStack) {
|
||||||
return getStackDescription((FluidStack) object);
|
return getStackDescription((FluidStack) object);
|
||||||
} else if (object instanceof Block) {
|
} else if (object instanceof Block) {
|
||||||
return new MCItemStack(new ItemStack((Block)object, 1, 0)).toString();
|
return new MCItemStack(new ItemStack((Block) object, 1, 0)).toString();
|
||||||
} else if (TweakerPlugin.isLoaded("Thaumcraft") && object instanceof AspectStack) {
|
|
||||||
return new MCAspectStack((AspectStack)object).toString();
|
|
||||||
} else if(TweakerPlugin.isLoaded("Thaumcraft") && object instanceof AspectList) {
|
|
||||||
List<AspectStack> stacks = new LinkedList<AspectStack>();
|
|
||||||
for(Aspect a : ((AspectList)object).getAspects()) {
|
|
||||||
stacks.add(new AspectStack(a, ((AspectList)object).getAmount(a)));
|
|
||||||
}
|
|
||||||
return(getListDescription(stacks));
|
|
||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
// Check if string specifies an oredict entry
|
// Check if string specifies an oredict entry
|
||||||
List<ItemStack> ores = OreDictionary.getOres((String)object);
|
List<ItemStack> ores = OreDictionary.getOres((String) object);
|
||||||
|
|
||||||
if(!ores.isEmpty()) {
|
if (!ores.isEmpty()) {
|
||||||
return "<ore:" + (String)object + ">";
|
return "<ore:" + (String) object + ">";
|
||||||
} else {
|
} else {
|
||||||
return "\"" + (String)object + "\"";
|
return "\"" + (String) object + "\"";
|
||||||
}
|
}
|
||||||
} else if (object instanceof List) {
|
} else if (object instanceof List) {
|
||||||
return getListDescription((List)object);
|
return getListDescription((List) object);
|
||||||
} else if(object instanceof Object[]) {
|
} else if (object instanceof Object[]) {
|
||||||
return getListDescription(Arrays.asList((Object[])object));
|
return getListDescription(Arrays.asList((Object[]) object));
|
||||||
} else if (object != null) {
|
} else if (object != null) {
|
||||||
return "\"" + object.toString() + "\"";
|
return "\"" + object.toString() + "\"";
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,7 +105,7 @@ public class LogHelper {
|
||||||
|
|
||||||
sb.append("<liquid:").append(stack.getFluid().getName()).append('>');
|
sb.append("<liquid:").append(stack.getFluid().getName()).append('>');
|
||||||
|
|
||||||
if(stack.amount > 1) {
|
if (stack.amount > 1) {
|
||||||
sb.append(" * ").append(stack.amount);
|
sb.append(" * ").append(stack.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,15 +115,15 @@ public class LogHelper {
|
||||||
public static String getListDescription(List<?> objects) {
|
public static String getListDescription(List<?> objects) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if(objects.isEmpty()) {
|
if (objects.isEmpty()) {
|
||||||
sb.append("[]");
|
sb.append("[]");
|
||||||
} else {
|
} else {
|
||||||
sb.append('[');
|
sb.append('[');
|
||||||
for(Object object : objects) {
|
for (Object object : objects) {
|
||||||
if(object instanceof List) {
|
if (object instanceof List) {
|
||||||
sb.append(getListDescription((List)object)).append(", ");
|
sb.append(getListDescription((List) object)).append(", ");
|
||||||
} else if(object instanceof Object[]) {
|
} else if (object instanceof Object[]) {
|
||||||
sb.append(getListDescription(Arrays.asList((Object[])object))).append(", ");
|
sb.append(getListDescription(Arrays.asList((Object[]) object))).append(", ");
|
||||||
} else {
|
} else {
|
||||||
sb.append(getStackDescription(object)).append(", ");
|
sb.append(getStackDescription(object)).append(", ");
|
||||||
}
|
}
|
||||||
|
@ -150,14 +136,14 @@ public class LogHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCraftingDescription(IRecipe recipe) {
|
public static String getCraftingDescription(IRecipe recipe) {
|
||||||
if(recipe instanceof ShapelessOreRecipe)
|
if (recipe instanceof ShapelessOreRecipe)
|
||||||
return LogHelper.getCraftingDescription((ShapelessOreRecipe)recipe);
|
return LogHelper.getCraftingDescription((ShapelessOreRecipe) recipe);
|
||||||
else if(recipe instanceof ShapedOreRecipe)
|
else if (recipe instanceof ShapedOreRecipe)
|
||||||
return LogHelper.getCraftingDescription((ShapedOreRecipe)recipe);
|
return LogHelper.getCraftingDescription((ShapedOreRecipe) recipe);
|
||||||
else if(recipe instanceof ShapelessRecipes)
|
else if (recipe instanceof ShapelessRecipes)
|
||||||
return LogHelper.getCraftingDescription((ShapelessRecipes)recipe);
|
return LogHelper.getCraftingDescription((ShapelessRecipes) recipe);
|
||||||
else if(recipe instanceof ShapedRecipes)
|
else if (recipe instanceof ShapedRecipes)
|
||||||
return LogHelper.getCraftingDescription((ShapedRecipes)recipe);
|
return LogHelper.getCraftingDescription((ShapedRecipes) recipe);
|
||||||
|
|
||||||
return recipe.toString();
|
return recipe.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ public class StringHelper {
|
||||||
|
|
||||||
public static String join(List<String> list, String conjunction) {
|
public static String join(List<String> list, String conjunction) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if(conjunction == null) {
|
if(conjunction == null) {
|
||||||
conjunction = ", ";
|
conjunction = ", ";
|
||||||
}
|
}
|
||||||
|
|
22
src/main/java/modtweaker2/mods/forestry/Forestry.java
Normal file
22
src/main/java/modtweaker2/mods/forestry/Forestry.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package modtweaker2.mods.forestry;
|
||||||
|
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import modtweaker2.mods.forestry.handlers.Carpenter;
|
||||||
|
import modtweaker2.mods.forestry.handlers.Centrifuge;
|
||||||
|
import modtweaker2.mods.forestry.handlers.Fermenter;
|
||||||
|
import modtweaker2.mods.forestry.handlers.Moistener;
|
||||||
|
import modtweaker2.mods.forestry.handlers.Squeezer;
|
||||||
|
import modtweaker2.mods.forestry.handlers.Still;
|
||||||
|
import modtweaker2.mods.forestry.handlers.ThermionicFabricator;
|
||||||
|
|
||||||
|
public class Forestry {
|
||||||
|
public Forestry() {
|
||||||
|
MineTweakerAPI.registerClass(Fermenter.class);
|
||||||
|
MineTweakerAPI.registerClass(Still.class);
|
||||||
|
MineTweakerAPI.registerClass(Moistener.class);
|
||||||
|
MineTweakerAPI.registerClass(Carpenter.class);
|
||||||
|
MineTweakerAPI.registerClass(Squeezer.class);
|
||||||
|
MineTweakerAPI.registerClass(Centrifuge.class);
|
||||||
|
MineTweakerAPI.registerClass(ThermionicFabricator.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package modtweaker2.mods.forestry;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ICraftingProvider;
|
||||||
|
import forestry.api.recipes.IForestryRecipe;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.utils.BaseListAddition;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class ForestryListAddition<T extends IForestryRecipe, C extends ICraftingProvider<T>> extends BaseListAddition<T> {
|
||||||
|
private final C craftingProvider;
|
||||||
|
|
||||||
|
protected ForestryListAddition(String name, C craftingProvider) {
|
||||||
|
super(name, new ArrayList<T>(craftingProvider.recipes()));
|
||||||
|
this.craftingProvider = craftingProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ForestryListAddition(String name, C craftingProvider, List<T> recipes) {
|
||||||
|
super(name, new ArrayList<T>(craftingProvider.recipes()), recipes);
|
||||||
|
this.craftingProvider = craftingProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected abstract String getRecipeInfo(T recipe);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void apply() {
|
||||||
|
for (T recipe : recipes) {
|
||||||
|
if (recipe != null) {
|
||||||
|
if (craftingProvider.addRecipe(recipe)) {
|
||||||
|
successful.add(recipe);
|
||||||
|
} else {
|
||||||
|
LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void undo() {
|
||||||
|
for (T recipe : successful) {
|
||||||
|
if (recipe != null) {
|
||||||
|
if (!craftingProvider.removeRecipe(recipe)) {
|
||||||
|
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package modtweaker2.mods.forestry;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ICraftingProvider;
|
||||||
|
import forestry.api.recipes.IForestryRecipe;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.utils.BaseListRemoval;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class ForestryListRemoval<T extends IForestryRecipe, C extends ICraftingProvider<T>> extends BaseListRemoval<T> {
|
||||||
|
private final C craftingProvider;
|
||||||
|
|
||||||
|
public ForestryListRemoval(String name, C craftingProvider, List<T> recipes) {
|
||||||
|
super(name, new ArrayList<T>(craftingProvider.recipes()), recipes);
|
||||||
|
this.craftingProvider = craftingProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected abstract String getRecipeInfo(T recipe);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void apply() {
|
||||||
|
for (T recipe : recipes) {
|
||||||
|
if (recipe != null) {
|
||||||
|
if (craftingProvider.removeRecipe(recipe)) {
|
||||||
|
successful.add(recipe);
|
||||||
|
} else {
|
||||||
|
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void undo() {
|
||||||
|
for (T recipe : successful) {
|
||||||
|
if (recipe != null) {
|
||||||
|
if (!craftingProvider.addRecipe(recipe)) {
|
||||||
|
LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogHelper.logError(String.format("Error restoring %s Recipe: null object", name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
138
src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java
Normal file
138
src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ICarpenterManager;
|
||||||
|
import forestry.api.recipes.ICarpenterRecipe;
|
||||||
|
import forestry.api.recipes.IDescriptiveRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.CarpenterRecipe;
|
||||||
|
import modtweaker2.mods.forestry.recipes.DescriptiveRecipe;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.*;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
@ZenClass("mods.forestry.Carpenter")
|
||||||
|
public class Carpenter {
|
||||||
|
|
||||||
|
public static final String name = "Forestry Carpenter";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a shaped recipe for the Carpenter
|
||||||
|
*
|
||||||
|
* @param output recipe output
|
||||||
|
* @param ingredients recipe ingredients
|
||||||
|
* @param packagingTime time per crafting operation
|
||||||
|
* @optionalParam box recipes casting item (optional)
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional IItemStack box, @Optional IItemStack[] remainingItems) {
|
||||||
|
if (remainingItems == null) {
|
||||||
|
remainingItems = new IItemStack[0];
|
||||||
|
}
|
||||||
|
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems));
|
||||||
|
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, null, toStack(box), craftRecipe)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a shaped recipe for the Carpenter
|
||||||
|
*
|
||||||
|
* @param output recipe output
|
||||||
|
* @param ingredients recipe ingredients
|
||||||
|
* @param fluidInput recipe fluid amount
|
||||||
|
* @param packagingTime time per crafting operation
|
||||||
|
* @optionalParam box recipes casting item (optional)
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, ILiquidStack fluidInput, int packagingTime, @Optional IItemStack box, @Optional IItemStack[] remainingItems) {
|
||||||
|
if (remainingItems == null) {
|
||||||
|
remainingItems = new IItemStack[0];
|
||||||
|
}
|
||||||
|
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems));
|
||||||
|
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IItemStack[][] transform(IItemStack[] arr, int N) {
|
||||||
|
int M = (arr.length + N - 1) / N;
|
||||||
|
IItemStack[][] mat = new IItemStack[M][];
|
||||||
|
int start = 0;
|
||||||
|
for (int r = 0; r < M; r++) {
|
||||||
|
int L = Math.min(N, arr.length - start);
|
||||||
|
mat[r] = java.util.Arrays.copyOfRange(arr, start, start + L);
|
||||||
|
start += L;
|
||||||
|
}
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends ForestryListAddition<ICarpenterRecipe, ICarpenterManager> {
|
||||||
|
|
||||||
|
public Add(ICarpenterRecipe recipe) {
|
||||||
|
super(Carpenter.name, RecipeManagers.carpenterManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a recipe for the Carpenter
|
||||||
|
*
|
||||||
|
* @param output = item output
|
||||||
|
* @optionalParam liquid = liquid input
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) {
|
||||||
|
List<ICarpenterRecipe> recipes = new LinkedList<ICarpenterRecipe>();
|
||||||
|
|
||||||
|
for (ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) {
|
||||||
|
if (recipe != null) {
|
||||||
|
ItemStack recipeResult = recipe.getCraftingGridRecipe().getRecipeOutput();
|
||||||
|
if (recipeResult != null && matches(output, toIItemStack(recipeResult))) {
|
||||||
|
if (liquid != null) {
|
||||||
|
if (matches(liquid, toILiquidStack(recipe.getFluidResource())))
|
||||||
|
recipes.add(recipe);
|
||||||
|
} else {
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Remove extends ForestryListRemoval<ICarpenterRecipe, ICarpenterManager> {
|
||||||
|
|
||||||
|
public Remove(List<ICarpenterRecipe> recipes) {
|
||||||
|
super(Carpenter.name, RecipeManagers.carpenterManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
110
src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java
Normal file
110
src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ICentrifugeManager;
|
||||||
|
import forestry.api.recipes.ICentrifugeRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import minetweaker.api.item.WeightedItemStack;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.CentrifugeRecipe;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
|
import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
|
||||||
|
@ZenClass("mods.forestry.Centrifuge")
|
||||||
|
public class Centrifuge {
|
||||||
|
|
||||||
|
public static final String name = "Forestry Centrifuge";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a recipe for the Centrifuge
|
||||||
|
*
|
||||||
|
* @param output List of items to produce with associated chance
|
||||||
|
* @param ingredient item input
|
||||||
|
* @param timePerItem time per item to process
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(WeightedItemStack[] output, IItemStack ingredient, int timePerItem) {
|
||||||
|
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||||
|
for (WeightedItemStack product : output) {
|
||||||
|
products.put(toStack(product.getStack()), product.getChance());
|
||||||
|
}
|
||||||
|
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(ingredient), products)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
@Deprecated
|
||||||
|
public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) {
|
||||||
|
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||||
|
int i = 0;
|
||||||
|
for (IItemStack product : output) {
|
||||||
|
products.put(toStack(product), ((float) chances[i] / 100));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends ForestryListAddition<ICentrifugeRecipe, ICentrifugeManager> {
|
||||||
|
public Add(ICentrifugeRecipe recipe) {
|
||||||
|
super(Centrifuge.name, RecipeManagers.centrifugeManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getInput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a recipe for the Centrifuge
|
||||||
|
*
|
||||||
|
* @param input item input
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeRecipe(IIngredient input) {
|
||||||
|
List<ICentrifugeRecipe> recipes = new LinkedList<ICentrifugeRecipe>();
|
||||||
|
|
||||||
|
for(ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) {
|
||||||
|
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Remove extends ForestryListRemoval<ICentrifugeRecipe, ICentrifugeManager> {
|
||||||
|
|
||||||
|
public Remove(List<ICentrifugeRecipe> recipes) {
|
||||||
|
super(Centrifuge.name, RecipeManagers.centrifugeManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getInput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
171
src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java
Normal file
171
src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import forestry.api.fuels.FermenterFuel;
|
||||||
|
import forestry.api.fuels.FuelManager;
|
||||||
|
import forestry.api.recipes.IFermenterManager;
|
||||||
|
import forestry.api.recipes.IFermenterRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.FermenterRecipe;
|
||||||
|
import modtweaker2.utils.BaseMapAddition;
|
||||||
|
import modtweaker2.utils.BaseMapRemoval;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.*;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
@ZenClass("mods.forestry.Fermenter")
|
||||||
|
public class Fermenter {
|
||||||
|
|
||||||
|
public static final String name = "Forestry Fermenter";
|
||||||
|
public static final String nameFuel = name + " (Fuel)";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a fermenter recipe. Amount of fluid output is calculated: fermentationValue * fluidOutputModifier
|
||||||
|
* Note: the actual consumption of fluid input depends on the fermentation fuel
|
||||||
|
*
|
||||||
|
* @param fluidOutput type of fluid produced
|
||||||
|
* @param resource organic item
|
||||||
|
* @param fluidInput type of fluid required in input
|
||||||
|
* @param fermentationValue amount of inputFluid on organic item requires
|
||||||
|
* @param fluidOutputModifier Output multiplier (this is usually a from the input fluid
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier) {
|
||||||
|
MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier, ILiquidStack fluidOutput) {
|
||||||
|
MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends ForestryListAddition<IFermenterRecipe, IFermenterManager> {
|
||||||
|
public Add(IFermenterRecipe recipe) {
|
||||||
|
super(Fermenter.name, RecipeManagers.fermenterManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IFermenterRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeRecipe(IIngredient input) {
|
||||||
|
List<IFermenterRecipe> recipes = new LinkedList<IFermenterRecipe>();
|
||||||
|
|
||||||
|
for(IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) {
|
||||||
|
// check for input items
|
||||||
|
if(recipe != null && recipe.getResource() != null && matches(input, toIItemStack(recipe.getResource()))) {
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for input liquids
|
||||||
|
if(recipe != null && recipe.getResource() != null && matches(input, toILiquidStack(recipe.getFluidResource()))) {
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Remove extends ForestryListRemoval<IFermenterRecipe, IFermenterManager> {
|
||||||
|
|
||||||
|
public Remove(List<IFermenterRecipe> recipes) {
|
||||||
|
super(Fermenter.name, RecipeManagers.fermenterManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(IFermenterRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds fermenter fuel.
|
||||||
|
* Note: the actual consumption of fluid input depends on the fermentation fuel
|
||||||
|
*
|
||||||
|
* @param item Item that is a valid fuel for the fermenter
|
||||||
|
* @param fermentPerCycle How much is fermented per work cycle, i.e. how much fluid of the input is consumed.
|
||||||
|
* @param burnDuration Amount of work cycles a single item of this fuel lasts before expiring.
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addFuel(IItemStack item, int fermentPerCycle, int burnDuration) {
|
||||||
|
MineTweakerAPI.apply(new AddFuel(new FermenterFuel(toStack(item), fermentPerCycle, burnDuration)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class AddFuel extends BaseMapAddition<ItemStack, FermenterFuel> {
|
||||||
|
public AddFuel(FermenterFuel fuelEntry) {
|
||||||
|
super(Fermenter.nameFuel, FuelManager.fermenterFuel);
|
||||||
|
recipes.put(fuelEntry.item, fuelEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(Entry<ItemStack, FermenterFuel> fuelEntry) {
|
||||||
|
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a fermenter fuel.
|
||||||
|
*
|
||||||
|
* @param fermenterItem Item that is a valid fuel for the fermenter
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeFuel(IIngredient fermenterItem) {
|
||||||
|
Map<ItemStack, FermenterFuel> fuelItems = new HashMap<ItemStack, FermenterFuel>();
|
||||||
|
|
||||||
|
for(Entry<ItemStack, FermenterFuel> fuelItem : FuelManager.fermenterFuel.entrySet()) {
|
||||||
|
if(fuelItem != null && matches(fermenterItem, toIItemStack(fuelItem.getValue().item))) {
|
||||||
|
fuelItems.put(fuelItem.getKey(), fuelItem.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!fuelItems.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new RemoveFuel(fuelItems));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, fermenterItem.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RemoveFuel extends BaseMapRemoval<ItemStack, FermenterFuel> {
|
||||||
|
public RemoveFuel(Map<ItemStack, FermenterFuel> recipes) {
|
||||||
|
super(Fermenter.nameFuel, FuelManager.fermenterFuel, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(Entry<ItemStack, FermenterFuel> fuelEntry) {
|
||||||
|
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
163
src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java
Normal file
163
src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import forestry.api.fuels.FuelManager;
|
||||||
|
import forestry.api.fuels.MoistenerFuel;
|
||||||
|
import forestry.api.recipes.IMoistenerManager;
|
||||||
|
import forestry.api.recipes.IMoistenerRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.MoistenerRecipe;
|
||||||
|
import modtweaker2.utils.BaseMapAddition;
|
||||||
|
import modtweaker2.utils.BaseMapRemoval;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
|
import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
@ZenClass("mods.forestry.Moistener")
|
||||||
|
public class Moistener {
|
||||||
|
|
||||||
|
public static final String name = "Forestry Moistener";
|
||||||
|
public static final String nameFuel = name + " (Fuel)";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a recipe for the Moistener
|
||||||
|
*
|
||||||
|
* @param output recipe output
|
||||||
|
* @param resource organic item
|
||||||
|
* @param timePerItem time per item to process
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(IItemStack output, IItemStack resource, int timePerItem) {
|
||||||
|
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(output), timePerItem)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) {
|
||||||
|
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(product), timePerItem)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends ForestryListAddition<IMoistenerRecipe, IMoistenerManager> {
|
||||||
|
public Add(IMoistenerRecipe recipe) {
|
||||||
|
super(Moistener.name, RecipeManagers.moistenerManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getProduct());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeRecipe(IIngredient output) {
|
||||||
|
List<IMoistenerRecipe> recipes = new LinkedList<IMoistenerRecipe>();
|
||||||
|
for (IMoistenerRecipe recipe : RecipeManagers.moistenerManager.recipes()) {
|
||||||
|
if (recipe != null && recipe.getProduct() != null && matches(output, toIItemStack(recipe.getProduct()))) {
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, output.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Remove extends ForestryListRemoval<IMoistenerRecipe, IMoistenerManager> {
|
||||||
|
public Remove(List<IMoistenerRecipe> recipes) {
|
||||||
|
super(Moistener.name, RecipeManagers.moistenerManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getProduct());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds moistener fuel.
|
||||||
|
*
|
||||||
|
* @param item The item to use
|
||||||
|
* @param product The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch)
|
||||||
|
* @param moistenerValue How much this item contributes to the final product of the moistener (i.e. mycelium)
|
||||||
|
* @param stage What stage this product represents. Resources with lower stage value will be consumed first. (First Stage is 0)
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addFuel(IItemStack item, IItemStack product, int moistenerValue, int stage) {
|
||||||
|
if(stage >= 0) {
|
||||||
|
MineTweakerAPI.apply(new AddFuel(new MoistenerFuel(toStack(item), toStack(product), moistenerValue, stage)));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe add for %s. Stage parameter must positive!", Moistener.name, item.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class AddFuel extends BaseMapAddition<ItemStack, MoistenerFuel> {
|
||||||
|
public AddFuel(MoistenerFuel fuelEntry) {
|
||||||
|
super(Moistener.nameFuel, FuelManager.moistenerResource);
|
||||||
|
recipes.put(fuelEntry.item, fuelEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(Entry<ItemStack, MoistenerFuel> fuelEntry) {
|
||||||
|
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a moistener fuel.
|
||||||
|
*
|
||||||
|
* @param moistenerItem Item that is a valid fuel for the moistener
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeFuel(IIngredient moistenerItem) {
|
||||||
|
Map<ItemStack, MoistenerFuel> fuelItems = new HashMap<ItemStack, MoistenerFuel>();
|
||||||
|
|
||||||
|
for(Entry<ItemStack, MoistenerFuel> fuelItem : FuelManager.moistenerResource.entrySet()) {
|
||||||
|
if(fuelItem != null && matches(moistenerItem, toIItemStack(fuelItem.getValue().item))) {
|
||||||
|
fuelItems.put(fuelItem.getKey(), fuelItem.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!fuelItems.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new RemoveFuel(fuelItems));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, moistenerItem.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RemoveFuel extends BaseMapRemoval<ItemStack, MoistenerFuel> {
|
||||||
|
public RemoveFuel(Map<ItemStack, MoistenerFuel> recipes) {
|
||||||
|
super(Moistener.nameFuel, FuelManager.moistenerResource, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(Entry<ItemStack, MoistenerFuel> fuelEntry) {
|
||||||
|
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
127
src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java
Normal file
127
src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ISqueezerManager;
|
||||||
|
import forestry.api.recipes.ISqueezerRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import minetweaker.api.item.WeightedItemStack;
|
||||||
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.SqueezerRecipe;
|
||||||
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.*;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
@ZenClass("mods.forestry.Squeezer")
|
||||||
|
public class Squeezer {
|
||||||
|
|
||||||
|
public static final String name = "Forestry Squeezer";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a recipe without additional item output
|
||||||
|
*
|
||||||
|
* @param fluidOutput recipe fluid amount
|
||||||
|
* @param ingredients recipe ingredients
|
||||||
|
* @param timePerItem time per crafting operation
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(ILiquidStack fluidOutput, int timePerItem, IItemStack[] ingredients) {
|
||||||
|
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), null, 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a recipe with additional item output
|
||||||
|
*
|
||||||
|
* @param fluidOutput recipe fluid amount
|
||||||
|
* @param itemOutput recipe output
|
||||||
|
* @param ingredients recipe ingredients
|
||||||
|
* @param timePerItem time per crafting operation
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(ILiquidStack fluidOutput, WeightedItemStack itemOutput, IItemStack[] ingredients, int timePerItem) {
|
||||||
|
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), toStack(itemOutput.getStack()), itemOutput.getChance())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
@Deprecated
|
||||||
|
public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, int chance) {
|
||||||
|
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(resources), toFluid(liquid), toStack(remnants), chance)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends ForestryListAddition<ISqueezerRecipe, ISqueezerManager> {
|
||||||
|
public Add(ISqueezerRecipe recipe) {
|
||||||
|
super(Squeezer.name, RecipeManagers.squeezerManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(ISqueezerRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getFluidOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a recipe for the Centrifuge
|
||||||
|
*
|
||||||
|
* @param liquid liquid output
|
||||||
|
* @param ingredients list of ingredients
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) {
|
||||||
|
List<ISqueezerRecipe> recipes = new LinkedList<ISqueezerRecipe>();
|
||||||
|
|
||||||
|
for (ISqueezerRecipe r : RecipeManagers.squeezerManager.recipes()) {
|
||||||
|
if (r != null && r.getFluidOutput() != null && matches(liquid, toILiquidStack(r.getFluidOutput()))) {
|
||||||
|
// optional check for ingredients
|
||||||
|
if (ingredients != null) {
|
||||||
|
boolean matched = false;
|
||||||
|
for (int i = 0; i < ingredients.length; i++) {
|
||||||
|
if ( matches(ingredients[i], toIItemStack(r.getResources()[i])) )
|
||||||
|
matched = true;
|
||||||
|
else {
|
||||||
|
matched = false;
|
||||||
|
// if one ingredients doesn't match abort all further checks
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if some ingredient doesn't match, the last one is false
|
||||||
|
if (matched)
|
||||||
|
recipes.add(r);
|
||||||
|
} else {
|
||||||
|
recipes.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Squeezer.name, LogHelper.getStackDescription(liquid)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Remove extends ForestryListRemoval<ISqueezerRecipe, ISqueezerManager> {
|
||||||
|
public Remove(List<ISqueezerRecipe> recipes) {
|
||||||
|
super(Squeezer.name, RecipeManagers.squeezerManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(ISqueezerRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getFluidOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
108
src/main/java/modtweaker2/mods/forestry/handlers/Still.java
Normal file
108
src/main/java/modtweaker2/mods/forestry/handlers/Still.java
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import forestry.api.recipes.IStillManager;
|
||||||
|
import forestry.api.recipes.IStillRecipe;
|
||||||
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.StillRecipe;
|
||||||
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||||
|
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
@ZenClass("mods.forestry.Still")
|
||||||
|
public class Still {
|
||||||
|
|
||||||
|
public static final String name = "Forestry Still";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a recipe for the Still
|
||||||
|
*
|
||||||
|
* @param fluidOutput recipe fluid amount
|
||||||
|
* @param fluidInput recipe fluid input
|
||||||
|
* @param timePerUnit time per crafting operation
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(ILiquidStack fluidOutput, ILiquidStack fluidInput, int timePerUnit) {
|
||||||
|
fluidOutput.amount(fluidOutput.getAmount() / 100);
|
||||||
|
fluidInput.amount(fluidInput.getAmount() / 100);
|
||||||
|
|
||||||
|
MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) {
|
||||||
|
output.amount(output.getAmount() / 100);
|
||||||
|
input.amount(input.getAmount() / 100);
|
||||||
|
|
||||||
|
MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(input), toFluid(output))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends ForestryListAddition<IStillRecipe, IStillManager> {
|
||||||
|
public Add(IStillRecipe recipe) {
|
||||||
|
super("Forestry Still", RecipeManagers.stillManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IStillRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a recipe for the Still
|
||||||
|
*
|
||||||
|
* @param output = liquid output
|
||||||
|
* @optionalParam liquid = liquid input
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeRecipe(IIngredient output, @Optional ILiquidStack input) {
|
||||||
|
List<IStillRecipe> recipes = new LinkedList<IStillRecipe>();
|
||||||
|
|
||||||
|
for (IStillRecipe r : RecipeManagers.stillManager.recipes()) {
|
||||||
|
if (r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) {
|
||||||
|
if (input != null) {
|
||||||
|
if (matches(input, toILiquidStack(r.getInput()))) {
|
||||||
|
recipes.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
recipes.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Still.name, LogHelper.getStackDescription(output)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Remove extends ForestryListRemoval<IStillRecipe, IStillManager> {
|
||||||
|
public Remove(List<IStillRecipe> recipes) {
|
||||||
|
super(Still.name, RecipeManagers.stillManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IStillRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,187 @@
|
||||||
|
package modtweaker2.mods.forestry.handlers;
|
||||||
|
|
||||||
|
import forestry.api.recipes.*;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListAddition;
|
||||||
|
import modtweaker2.mods.forestry.ForestryListRemoval;
|
||||||
|
import modtweaker2.mods.forestry.recipes.DescriptiveRecipe;
|
||||||
|
import modtweaker2.mods.forestry.recipes.FabricatorRecipe;
|
||||||
|
import modtweaker2.mods.forestry.recipes.FabricatorSmeltingRecipe;
|
||||||
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.*;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
@ZenClass("mods.forestry.ThermionicFabricator")
|
||||||
|
public class ThermionicFabricator {
|
||||||
|
|
||||||
|
public static final String nameSmelting = "Forestry Thermionic Fabricator (Smelting)";
|
||||||
|
public static final String nameCasting = "Forestry Thermionic Fabricator (Casting)";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a smelting recipe for the Thermionic Fabricator
|
||||||
|
*
|
||||||
|
* @param fluidOutput recipe fluid amount
|
||||||
|
* @param itemInput recipe input input
|
||||||
|
* @param meltingPoint point at where itemInput melts down
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addSmelting(int fluidOutput, IItemStack itemInput, int meltingPoint) {
|
||||||
|
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
|
||||||
|
MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ZenMethod
|
||||||
|
public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) {
|
||||||
|
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
|
||||||
|
MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a casting recipe for the Thermionic Fabricator
|
||||||
|
*
|
||||||
|
* @param output recipe output item
|
||||||
|
* @param ingredients list of input items
|
||||||
|
* @param fluidInput recipe fluid input
|
||||||
|
* @param plan recipe plan item
|
||||||
|
*/
|
||||||
|
@ZenMethod
|
||||||
|
public static void addCast(IItemStack output, IIngredient[][] ingredients, int fluidInput, @Optional IItemStack plan, @Optional IItemStack[] remainingItems) {
|
||||||
|
if (remainingItems == null) {
|
||||||
|
remainingItems = new IItemStack[0];
|
||||||
|
}
|
||||||
|
IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems));
|
||||||
|
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), FluidRegistry.getFluidStack("glass", fluidInput), recipe)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ZenMethod
|
||||||
|
public static void addCast(ILiquidStack fluidInput, IIngredient[][] ingredients, IItemStack plan, IItemStack output, @Optional IItemStack[] remainingItems) {
|
||||||
|
if (remainingItems == null) {
|
||||||
|
remainingItems = new IItemStack[0];
|
||||||
|
}
|
||||||
|
IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems));
|
||||||
|
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), toFluid(fluidInput), recipe)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Implements the actions to add a recipe
|
||||||
|
Since the machine has two crafting Steps, this is a constructors for both
|
||||||
|
*/
|
||||||
|
private static class AddSmelting extends ForestryListAddition<IFabricatorSmeltingRecipe, IFabricatorSmeltingManager> {
|
||||||
|
|
||||||
|
public AddSmelting(IFabricatorSmeltingRecipe recipe) {
|
||||||
|
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getResource());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class AddCast extends ForestryListAddition<IFabricatorRecipe, IFabricatorManager> {
|
||||||
|
|
||||||
|
public AddCast(IFabricatorRecipe recipe) {
|
||||||
|
super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager);
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IFabricatorRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getRecipeOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeSmelting(IIngredient itemInput) {
|
||||||
|
List<IFabricatorSmeltingRecipe> recipes = new LinkedList<IFabricatorSmeltingRecipe>();
|
||||||
|
|
||||||
|
for (IFabricatorSmeltingRecipe r : RecipeManagers.fabricatorSmeltingManager.recipes()) {
|
||||||
|
if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) {
|
||||||
|
recipes.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new RemoveSmelting(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, itemInput.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeCast(IIngredient product) {
|
||||||
|
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
|
||||||
|
|
||||||
|
for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) {
|
||||||
|
if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) {
|
||||||
|
recipes.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new RemoveCasts(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeCasts(IIngredient product) {
|
||||||
|
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
|
||||||
|
|
||||||
|
for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) {
|
||||||
|
if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) {
|
||||||
|
recipes.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new RemoveCasts(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RemoveSmelting extends ForestryListRemoval<IFabricatorSmeltingRecipe, IFabricatorSmeltingManager> {
|
||||||
|
public RemoveSmelting(List<IFabricatorSmeltingRecipe> recipes) {
|
||||||
|
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getResource());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RemoveCasts extends ForestryListRemoval<IFabricatorRecipe, IFabricatorManager> {
|
||||||
|
public RemoveCasts(List<IFabricatorRecipe> recipes) {
|
||||||
|
super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(IFabricatorRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getRecipeOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ICarpenterRecipe;
|
||||||
|
import forestry.api.recipes.IDescriptiveRecipe;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class CarpenterRecipe implements ICarpenterRecipe {
|
||||||
|
|
||||||
|
private final int packagingTime;
|
||||||
|
@Nullable
|
||||||
|
private final FluidStack liquid;
|
||||||
|
@Nullable
|
||||||
|
private final ItemStack box;
|
||||||
|
private final IDescriptiveRecipe internal;
|
||||||
|
|
||||||
|
public CarpenterRecipe(int packagingTime, @Nullable FluidStack liquid, @Nullable ItemStack box, IDescriptiveRecipe internal) {
|
||||||
|
this.packagingTime = packagingTime;
|
||||||
|
this.liquid = liquid;
|
||||||
|
this.box = box;
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPackagingTime() {
|
||||||
|
return packagingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public ItemStack getBox() {
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public FluidStack getFluidResource() {
|
||||||
|
return liquid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IDescriptiveRecipe getCraftingGridRecipe() {
|
||||||
|
return internal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import forestry.api.recipes.ICentrifugeRecipe;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class CentrifugeRecipe implements ICentrifugeRecipe {
|
||||||
|
|
||||||
|
private final int processingTime;
|
||||||
|
private final ItemStack input;
|
||||||
|
private final Map<ItemStack, Float> outputs;
|
||||||
|
|
||||||
|
public CentrifugeRecipe(int processingTime, ItemStack input, Map<ItemStack, Float> outputs) {
|
||||||
|
this.processingTime = processingTime;
|
||||||
|
this.input = input;
|
||||||
|
this.outputs = outputs;
|
||||||
|
|
||||||
|
for (ItemStack item : outputs.keySet()) {
|
||||||
|
if (item == null) {
|
||||||
|
throw new IllegalArgumentException("Tried to register a null product of " + input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getProcessingTime() {
|
||||||
|
return processingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ItemStack> getProducts(Random random) {
|
||||||
|
List<ItemStack> products = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
|
for (Map.Entry<ItemStack, Float> entry : this.outputs.entrySet()) {
|
||||||
|
float probability = entry.getValue();
|
||||||
|
|
||||||
|
if (probability >= 1.0) {
|
||||||
|
products.add(entry.getKey().copy());
|
||||||
|
} else if (random.nextFloat() < probability) {
|
||||||
|
products.add(entry.getKey().copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<ItemStack, Float> getAllProducts() {
|
||||||
|
return ImmutableMap.copyOf(outputs);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import forestry.api.recipes.IDescriptiveRecipe;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
|
|
||||||
|
public class DescriptiveRecipe implements IDescriptiveRecipe {
|
||||||
|
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
private final ShapedOreRecipe recipe;
|
||||||
|
private final ItemStack[] remainingItems;
|
||||||
|
|
||||||
|
public DescriptiveRecipe(int width, int height, Object[] ingredients, ItemStack output, ItemStack[] remainingItems) {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.recipe = new ShapedOreRecipe(output, ingredients);
|
||||||
|
this.remainingItems = remainingItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getRecipeOutput() {
|
||||||
|
return recipe.getRecipeOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
||||||
|
return remainingItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getIngredients() {
|
||||||
|
return recipe.getInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(InventoryCrafting inventoryCrafting, World world) {
|
||||||
|
return recipe.matches(inventoryCrafting, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
|
||||||
|
return recipe.getCraftingResult(inventoryCrafting);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRecipeSize() {
|
||||||
|
return width * height;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import forestry.api.recipes.IDescriptiveRecipe;
|
||||||
|
import forestry.api.recipes.IFabricatorRecipe;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class FabricatorRecipe implements IFabricatorRecipe {
|
||||||
|
|
||||||
|
private final ItemStack plan;
|
||||||
|
private final FluidStack molten;
|
||||||
|
private final IDescriptiveRecipe internal;
|
||||||
|
|
||||||
|
public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, ItemStack[] remainingItems, Object[] ingredients) {
|
||||||
|
this(plan, molten, new DescriptiveRecipe(3, 3, ingredients, result, remainingItems));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FabricatorRecipe(ItemStack plan, FluidStack molten, IDescriptiveRecipe internal) {
|
||||||
|
this.plan = plan;
|
||||||
|
this.molten = molten;
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getIngredients() {
|
||||||
|
return internal.getIngredients();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth() {
|
||||||
|
return internal.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return internal.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public ItemStack getPlan() {
|
||||||
|
return plan;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack getLiquid() {
|
||||||
|
return molten;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getRecipeOutput() {
|
||||||
|
return internal.getRecipeOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
||||||
|
|
||||||
|
public class FabricatorSmeltingRecipe implements IFabricatorSmeltingRecipe {
|
||||||
|
private final ItemStack resource;
|
||||||
|
private final FluidStack product;
|
||||||
|
private final int meltingPoint;
|
||||||
|
|
||||||
|
public FabricatorSmeltingRecipe(ItemStack resource, FluidStack molten, int meltingPoint) {
|
||||||
|
if (resource == null) {
|
||||||
|
throw new IllegalArgumentException("Resource cannot be null");
|
||||||
|
}
|
||||||
|
if (molten == null) {
|
||||||
|
throw new IllegalArgumentException("Molten cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resource = resource;
|
||||||
|
this.product = molten;
|
||||||
|
this.meltingPoint = meltingPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getResource() {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FluidStack getProduct() {
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMeltingPoint() {
|
||||||
|
return meltingPoint;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import forestry.api.recipes.IFermenterRecipe;
|
||||||
|
|
||||||
|
public class FermenterRecipe implements IFermenterRecipe {
|
||||||
|
|
||||||
|
private final ItemStack resource;
|
||||||
|
private final int fermentationValue;
|
||||||
|
private final float modifier;
|
||||||
|
private final Fluid output;
|
||||||
|
private final FluidStack fluidResource;
|
||||||
|
|
||||||
|
public FermenterRecipe(ItemStack resource, int fermentationValue, float modifier, Fluid output, FluidStack fluidResource) {
|
||||||
|
if (resource == null) {
|
||||||
|
throw new NullPointerException("Fermenter Resource cannot be null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output == null) {
|
||||||
|
throw new NullPointerException("Fermenter Output cannot be null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fluidResource == null) {
|
||||||
|
throw new NullPointerException("Fermenter Liquid cannot be null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// assume that fermenter recipes want to use Forestry's honey and not the legacy "fluid.honey"
|
||||||
|
if (fluidResource.getFluid().getName().equals("fluid.honey")) {
|
||||||
|
fluidResource = new FluidStack(FluidRegistry.getFluid("fluid.for.honey"), fluidResource.amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resource = resource;
|
||||||
|
this.fermentationValue = fermentationValue;
|
||||||
|
this.modifier = modifier;
|
||||||
|
this.output = output;
|
||||||
|
this.fluidResource = fluidResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getResource() {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack getFluidResource() {
|
||||||
|
return fluidResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFermentationValue() {
|
||||||
|
return fermentationValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getModifier() {
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fluid getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import forestry.api.recipes.IMoistenerRecipe;
|
||||||
|
|
||||||
|
public class MoistenerRecipe implements IMoistenerRecipe {
|
||||||
|
|
||||||
|
private final int timePerItem;
|
||||||
|
private final ItemStack resource;
|
||||||
|
private final ItemStack product;
|
||||||
|
|
||||||
|
public MoistenerRecipe(ItemStack resource, ItemStack product, int timePerItem) {
|
||||||
|
this.timePerItem = timePerItem;
|
||||||
|
this.resource = resource;
|
||||||
|
this.product = product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimePerItem() {
|
||||||
|
return timePerItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getResource() {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getProduct() {
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import forestry.api.recipes.ISqueezerRecipe;
|
||||||
|
|
||||||
|
public class SqueezerRecipe implements ISqueezerRecipe {
|
||||||
|
|
||||||
|
private final int processingTime;
|
||||||
|
private final ItemStack[] resources;
|
||||||
|
private final FluidStack fluidOutput;
|
||||||
|
private final ItemStack remnants;
|
||||||
|
private final float remnantsChance;
|
||||||
|
|
||||||
|
public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, ItemStack remnants, float remnantsChance) {
|
||||||
|
this.processingTime = processingTime;
|
||||||
|
this.resources = resources;
|
||||||
|
this.fluidOutput = fluidOutput;
|
||||||
|
this.remnants = remnants;
|
||||||
|
this.remnantsChance = remnantsChance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack[] getResources() {
|
||||||
|
return resources;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getRemnants() {
|
||||||
|
return remnants;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getRemnantsChance() {
|
||||||
|
return remnantsChance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack getFluidOutput() {
|
||||||
|
return fluidOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getProcessingTime() {
|
||||||
|
return processingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package modtweaker2.mods.forestry.recipes;
|
||||||
|
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import forestry.api.recipes.IStillRecipe;
|
||||||
|
|
||||||
|
public class StillRecipe implements IStillRecipe {
|
||||||
|
private final int timePerUnit;
|
||||||
|
private final FluidStack input;
|
||||||
|
private final FluidStack output;
|
||||||
|
|
||||||
|
public StillRecipe(int timePerUnit, FluidStack input, FluidStack output) {
|
||||||
|
this.timePerUnit = timePerUnit;
|
||||||
|
if (input == null) {
|
||||||
|
throw new IllegalArgumentException("Still recipes need an input. Input was null.");
|
||||||
|
}
|
||||||
|
if (output == null) {
|
||||||
|
throw new IllegalArgumentException("Still recipes need an output. Output was null.");
|
||||||
|
}
|
||||||
|
this.input = input;
|
||||||
|
this.output = output;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCyclesPerUnit() {
|
||||||
|
return timePerUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
16
src/main/java/modtweaker2/mods/tconstruct/TConstruct.java
Normal file
16
src/main/java/modtweaker2/mods/tconstruct/TConstruct.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package modtweaker2.mods.tconstruct;
|
||||||
|
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import modtweaker2.brackets.MaterialBracketHandler;
|
||||||
|
|
||||||
|
public class TConstruct {
|
||||||
|
public TConstruct() {
|
||||||
|
// MineTweakerAPI.registerClass(Casting.class);
|
||||||
|
// MineTweakerAPI.registerClass(Drying.class);
|
||||||
|
// MineTweakerAPI.registerClass(Smeltery.class);
|
||||||
|
// MineTweakerAPI.registerClass(Modifiers.class);
|
||||||
|
// MineTweakerAPI.registerClass(TiCTweaks.class);
|
||||||
|
// MineTweakerAPI.registerClass(ToolStats.class);
|
||||||
|
MineTweakerAPI.registerBracketHandler(new MaterialBracketHandler());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package modtweaker2.mods.tconstruct;
|
||||||
|
|
||||||
|
import modtweaker2.helpers.ReflectionHelper;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import slimeknights.tconstruct.library.DryingRecipe;
|
||||||
|
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||||
|
import slimeknights.tconstruct.library.modifiers.IModifier;
|
||||||
|
import slimeknights.tconstruct.library.smeltery.AlloyRecipe;
|
||||||
|
import slimeknights.tconstruct.library.smeltery.CastingRecipe;
|
||||||
|
import slimeknights.tconstruct.library.smeltery.MeltingRecipe;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TConstructHelper {
|
||||||
|
public static List<AlloyRecipe> alloys = null;
|
||||||
|
public static List<CastingRecipe> basinCasting = null;
|
||||||
|
public static List<CastingRecipe> tableCasting = null;
|
||||||
|
public static List<MeltingRecipe> smeltingList = null;
|
||||||
|
// public static Map<ItemMetaWrapper, Integer> temperatureList = null;
|
||||||
|
// public static Map<ItemMetaWrapper, ItemStack> renderIndex = null;
|
||||||
|
public static List<FluidStack> fuelList = new ArrayList<FluidStack>();
|
||||||
|
public static List<IModifier> modifiers = new ArrayList<IModifier>();
|
||||||
|
public static List<IModifier> modifiers_clone = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
alloys = TinkerRegistry.getAlloys();
|
||||||
|
smeltingList = TinkerRegistry.getAllMeltingRecipies();
|
||||||
|
// temperatureList = tconstruct.library.crafting.Smeltery.getTemperatureList();
|
||||||
|
// renderIndex = tconstruct.library.crafting.Smeltery.getRenderIndex();
|
||||||
|
basinCasting = TinkerRegistry.getAllBasinCastingRecipes();
|
||||||
|
tableCasting = TinkerRegistry.getAllTableCastingRecipes();
|
||||||
|
modifiers.addAll(TinkerRegistry.getAllModifiers());
|
||||||
|
modifiers_clone = new ArrayList<IModifier>(modifiers);
|
||||||
|
fuelList.addAll(TinkerRegistry.getSmelteryFuels());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TConstructHelper() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns a Drying Recipe, using reflection as the constructor is not visible
|
||||||
|
public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) {
|
||||||
|
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class),
|
||||||
|
input,
|
||||||
|
time,
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package modtweaker2.mods.tconstruct.actions;
|
||||||
|
|
||||||
|
import minetweaker.IUndoableAction;
|
||||||
|
import modtweaker2.brackets.util.IMaterial;
|
||||||
|
import slimeknights.tconstruct.library.materials.HeadMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.IMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
public class SetAttackAction implements IUndoableAction {
|
||||||
|
|
||||||
|
private final IMaterial material;
|
||||||
|
private final String stat;
|
||||||
|
private final float newValue;
|
||||||
|
private final float oldValue;
|
||||||
|
|
||||||
|
public SetAttackAction(IMaterial material, String stat, float newValue) {
|
||||||
|
this.material = material;
|
||||||
|
this.stat = stat;
|
||||||
|
this.newValue = newValue;
|
||||||
|
this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).attack;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(Material material, String stat, float attack) {
|
||||||
|
IMaterialStats oldStat = material.getStats(stat);
|
||||||
|
if (oldStat instanceof HeadMaterialStats) {
|
||||||
|
HeadMaterialStats headStat = (HeadMaterialStats) oldStat;
|
||||||
|
HeadMaterialStats newHead = new HeadMaterialStats(headStat.durability, headStat.miningspeed, attack, headStat.harvestLevel);
|
||||||
|
material.addStats(newHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
set((Material) material.getInternal(), stat, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUndo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
set((Material) material.getInternal(), stat, oldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describe() {
|
||||||
|
return "Setting Attack of " + material.getName() + " to " + newValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describeUndo() {
|
||||||
|
return "Reverting Attack of " + material.getName() + " to " + oldValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getOverrideKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package modtweaker2.mods.tconstruct.actions;
|
||||||
|
|
||||||
|
import minetweaker.IUndoableAction;
|
||||||
|
import modtweaker2.brackets.util.IMaterial;
|
||||||
|
import slimeknights.tconstruct.library.materials.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
public class SetDurabilityAction implements IUndoableAction {
|
||||||
|
|
||||||
|
private final IMaterial material;
|
||||||
|
private final String stat;
|
||||||
|
private final int newValue;
|
||||||
|
private final int oldValue;
|
||||||
|
|
||||||
|
public SetDurabilityAction(IMaterial material, String stat, int newValue) {
|
||||||
|
this.material = material;
|
||||||
|
this.stat = stat;
|
||||||
|
this.newValue = newValue;
|
||||||
|
this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).durability;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(Material material, String stat, int durability) {
|
||||||
|
IMaterialStats oldStat = material.getStats(stat);
|
||||||
|
if (oldStat instanceof HeadMaterialStats) {
|
||||||
|
HeadMaterialStats headStat = (HeadMaterialStats) oldStat;
|
||||||
|
HeadMaterialStats newHead = new HeadMaterialStats(durability, headStat.miningspeed, headStat.attack, headStat.harvestLevel);
|
||||||
|
material.addStats(newHead);
|
||||||
|
} else if (oldStat instanceof HandleMaterialStats) {
|
||||||
|
HandleMaterialStats handleStat = (HandleMaterialStats) oldStat;
|
||||||
|
HandleMaterialStats newHandle = new HandleMaterialStats(handleStat.modifier, durability);
|
||||||
|
material.addStats(newHandle);
|
||||||
|
} else if (oldStat instanceof ExtraMaterialStats) {
|
||||||
|
ExtraMaterialStats newExtra = new ExtraMaterialStats(durability);
|
||||||
|
material.addStats(newExtra);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
set((Material) material.getInternal(), stat, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUndo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
set((Material) material.getInternal(),stat, oldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describe() {
|
||||||
|
return "Setting durability of " + material.getName() + " to " + newValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describeUndo() {
|
||||||
|
return "Reverting durability of " + material.getName() + " to " + oldValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getOverrideKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package modtweaker2.mods.tconstruct.actions;
|
||||||
|
|
||||||
|
import minetweaker.IUndoableAction;
|
||||||
|
import modtweaker2.brackets.util.IMaterial;
|
||||||
|
import slimeknights.tconstruct.library.materials.HeadMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.IMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
public class SetHarvestLevelAction implements IUndoableAction {
|
||||||
|
|
||||||
|
private final IMaterial material;
|
||||||
|
private final String stat;
|
||||||
|
private final int newValue;
|
||||||
|
private final int oldValue;
|
||||||
|
|
||||||
|
public SetHarvestLevelAction(IMaterial material, String stat, int newValue) {
|
||||||
|
this.material = material;
|
||||||
|
this.stat = stat;
|
||||||
|
this.newValue = newValue;
|
||||||
|
this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).harvestLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(Material material, String stat, int level) {
|
||||||
|
IMaterialStats oldStat = material.getStats(stat);
|
||||||
|
if (oldStat instanceof HeadMaterialStats) {
|
||||||
|
HeadMaterialStats headStat = (HeadMaterialStats) oldStat;
|
||||||
|
HeadMaterialStats newHead = new HeadMaterialStats(headStat.durability, headStat.miningspeed, headStat.attack, level);
|
||||||
|
material.addStats(newHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
set((Material) material.getInternal(), stat, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUndo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
set((Material) material.getInternal(), stat, oldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describe() {
|
||||||
|
return "Setting durability of " + material.getName() + " to " + newValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describeUndo() {
|
||||||
|
return "Reverting durability of " + material.getName() + " to " + oldValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getOverrideKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package modtweaker2.mods.tconstruct.actions;
|
||||||
|
|
||||||
|
import minetweaker.IUndoableAction;
|
||||||
|
import modtweaker2.brackets.util.IMaterial;
|
||||||
|
import slimeknights.tconstruct.library.materials.HeadMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.IMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
public class SetMiningSpeedAction implements IUndoableAction {
|
||||||
|
|
||||||
|
private final IMaterial material;
|
||||||
|
private final String stat;
|
||||||
|
private final float newValue;
|
||||||
|
private final float oldValue;
|
||||||
|
|
||||||
|
public SetMiningSpeedAction(IMaterial material, String stat, float newValue) {
|
||||||
|
this.material = material;
|
||||||
|
this.stat = stat;
|
||||||
|
this.newValue = newValue;
|
||||||
|
this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).miningspeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(Material material, String stat, float miningSpeed) {
|
||||||
|
IMaterialStats oldStat = material.getStats(stat);
|
||||||
|
if (oldStat instanceof HeadMaterialStats) {
|
||||||
|
HeadMaterialStats headStat = (HeadMaterialStats) oldStat;
|
||||||
|
HeadMaterialStats newHead = new HeadMaterialStats(headStat.durability, miningSpeed, headStat.attack, headStat.harvestLevel);
|
||||||
|
material.addStats(newHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
set((Material) material.getInternal(), stat, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUndo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
set((Material) material.getInternal(), stat, oldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describe() {
|
||||||
|
return "Setting MiningSpeed of " + material.getName() + " to " + newValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describeUndo() {
|
||||||
|
return "Reverting MiningSpeed of " + material.getName() + " to " + oldValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getOverrideKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package modtweaker2.mods.tconstruct.actions;
|
||||||
|
|
||||||
|
import minetweaker.IUndoableAction;
|
||||||
|
import modtweaker2.brackets.util.IMaterial;
|
||||||
|
import slimeknights.tconstruct.library.materials.HandleMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.IMaterialStats;
|
||||||
|
import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jared on 6/16/2016.
|
||||||
|
*/
|
||||||
|
public class SetModifierAction implements IUndoableAction {
|
||||||
|
|
||||||
|
private final IMaterial material;
|
||||||
|
private final String stat;
|
||||||
|
private final float newValue;
|
||||||
|
private final float oldValue;
|
||||||
|
|
||||||
|
public SetModifierAction(IMaterial material, String stat, float newValue) {
|
||||||
|
this.material = material;
|
||||||
|
this.stat = stat;
|
||||||
|
this.newValue = newValue;
|
||||||
|
this.oldValue = ((HandleMaterialStats) ((Material) material.getInternal()).getStats("handle")).modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(Material material, String stat, float modifier) {
|
||||||
|
IMaterialStats oldStat = material.getStats(stat);
|
||||||
|
if (oldStat instanceof HandleMaterialStats) {
|
||||||
|
HandleMaterialStats handleStat = (HandleMaterialStats) oldStat;
|
||||||
|
HandleMaterialStats newHandle = new HandleMaterialStats(modifier, handleStat.durability);
|
||||||
|
material.addStats(newHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
set((Material) material.getInternal(), stat, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUndo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
set((Material) material.getInternal(), stat, oldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describe() {
|
||||||
|
return "Setting Modifier of " + material.getName() + " to " + newValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String describeUndo() {
|
||||||
|
return "Reverting Modifier of " + material.getName() + " to " + oldValue + " for " + stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getOverrideKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package modtweaker2.mods.tconstruct.commands;
|
||||||
|
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.player.IPlayer;
|
||||||
|
import minetweaker.api.server.ICommandFunction;
|
||||||
|
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||||
|
import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.LogHelper.logPrinted;
|
||||||
|
|
||||||
|
public class MaterialLogger implements ICommandFunction {
|
||||||
|
@Override
|
||||||
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
|
MineTweakerAPI.logCommand(TinkerRegistry.getAllMaterials().size() + " Materials:");
|
||||||
|
for (Material entry : TinkerRegistry.getAllMaterials()) {
|
||||||
|
MineTweakerAPI.logCommand(entry.getLocalizedName());
|
||||||
|
}
|
||||||
|
logPrinted(player);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package modtweaker2.mods.tconstruct.commands;
|
||||||
|
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.player.IPlayer;
|
||||||
|
import minetweaker.api.server.ICommandFunction;
|
||||||
|
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
import slimeknights.tconstruct.library.modifiers.IModifier;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.LogHelper.logPrinted;
|
||||||
|
|
||||||
|
public class ModifierLogger implements ICommandFunction{
|
||||||
|
@Override
|
||||||
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
|
MineTweakerAPI.logCommand(TConstructHelper.modifiers.size() + " Tinker's Construct modifiers:");
|
||||||
|
for (IModifier modifier : TConstructHelper.modifiers) {
|
||||||
|
if (!modifier.getIdentifier().equals(""))
|
||||||
|
MineTweakerAPI.logCommand(modifier.getIdentifier());
|
||||||
|
}
|
||||||
|
logPrinted(player);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
package modtweaker2.mods.tconstruct.commands;
|
||||||
|
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.MineTweakerImplementationAPI;
|
||||||
|
import minetweaker.api.player.IPlayer;
|
||||||
|
import minetweaker.api.server.ICommandFunction;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.helpers.StringHelper;
|
||||||
|
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
import slimeknights.tconstruct.library.DryingRecipe;
|
||||||
|
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||||
|
import slimeknights.tconstruct.library.smeltery.AlloyRecipe;
|
||||||
|
import slimeknights.tconstruct.library.smeltery.CastingRecipe;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TConstructLogger implements ICommandFunction {
|
||||||
|
private static final List<String> validArguments = new LinkedList<String>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
validArguments.add("Casting");
|
||||||
|
validArguments.add("Drying");
|
||||||
|
validArguments.add("Smeltery");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
|
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
|
||||||
|
|
||||||
|
if (!validArguments.containsAll(args)) {
|
||||||
|
if (player != null) {
|
||||||
|
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (args.isEmpty() || args.contains("Casting")) {
|
||||||
|
for (CastingRecipe recipe : TConstructHelper.basinCasting) {
|
||||||
|
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);",
|
||||||
|
LogHelper.getStackDescription(recipe.getResult()),
|
||||||
|
LogHelper.getStackDescription(recipe.getFluid()),
|
||||||
|
LogHelper.getStackDescription(recipe.cast),
|
||||||
|
recipe.consumesCast(),
|
||||||
|
recipe.getTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CastingRecipe recipe : TConstructHelper.tableCasting) {
|
||||||
|
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);",
|
||||||
|
LogHelper.getStackDescription(recipe.getResult()),
|
||||||
|
LogHelper.getStackDescription(recipe.getFluid()),
|
||||||
|
LogHelper.getStackDescription(recipe.cast),
|
||||||
|
recipe.consumesCast(),
|
||||||
|
recipe.getTime()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.isEmpty() || args.contains("Drying")) {
|
||||||
|
for (DryingRecipe recipe : TinkerRegistry.getAllDryingRecipes()) {
|
||||||
|
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Drying.addRecipe(%s, %s, %d);",
|
||||||
|
LogHelper.getStackDescription(recipe.input),
|
||||||
|
LogHelper.getStackDescription(recipe.getResult()),
|
||||||
|
recipe.time));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(args.isEmpty() || args.contains("Smeltery")) {
|
||||||
|
// for(MeltingRecipe recipe : TConstructHelper.smeltingList) {
|
||||||
|
// int temperature = recipe.getTemperature();
|
||||||
|
// ItemStack renderItem = TConstructHelper.renderIndex.get(recipe.getKey());
|
||||||
|
//
|
||||||
|
// MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);",
|
||||||
|
// LogHelper.getStackDescription(new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)),
|
||||||
|
// LogHelper.getStackDescription(recipe.getValue()),
|
||||||
|
// temperature,
|
||||||
|
// LogHelper.getStackDescription(renderItem)));
|
||||||
|
// }
|
||||||
|
|
||||||
|
for (AlloyRecipe recipe : TConstructHelper.alloys) {
|
||||||
|
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addAlloy(%s, %s);",
|
||||||
|
LogHelper.getStackDescription(recipe.getResult()),
|
||||||
|
LogHelper.getListDescription(recipe.getFluids())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// for(FluidStack fuel : TConstructHelper.fuelList) {
|
||||||
|
// MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addFuel(%s, %d, %d);",
|
||||||
|
// LogHelper.getStackDescription(new FluidStack(fuel.getFluid(), 1)),
|
||||||
|
// fuel[0],
|
||||||
|
// fuel.getValue()[1]));
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java
Normal file
133
src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
//package modtweaker2.mods.tconstruct.handlers;
|
||||||
|
//
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toFluid;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
|
//import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
//
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.LinkedList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//import minetweaker.MineTweakerAPI;
|
||||||
|
//import minetweaker.api.item.IIngredient;
|
||||||
|
//import minetweaker.api.item.IItemStack;
|
||||||
|
//import minetweaker.api.item.IngredientAny;
|
||||||
|
//import minetweaker.api.liquid.ILiquidStack;
|
||||||
|
//import modtweaker2.helpers.LogHelper;
|
||||||
|
//import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
//import modtweaker2.utils.BaseListAddition;
|
||||||
|
//import modtweaker2.utils.BaseListRemoval;
|
||||||
|
//import stanhebben.zenscript.annotations.Optional;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
//import tconstruct.library.crafting.CastingRecipe;
|
||||||
|
//
|
||||||
|
//@ZenClass("mods.tconstruct.Casting")
|
||||||
|
//public class Casting {
|
||||||
|
//
|
||||||
|
// protected static final String name = "TConstruct Casting";
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
|
||||||
|
// if(metal == null || output == null) {
|
||||||
|
// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
|
||||||
|
// if(metal == null || output == null) {
|
||||||
|
// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.tableCasting));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //Passes the list to the base list implementation, and adds the recipe
|
||||||
|
// private static class Add extends BaseListAddition<CastingRecipe> {
|
||||||
|
// public Add(CastingRecipe recipe, ArrayList<CastingRecipe> list) {
|
||||||
|
// super(Casting.name, list);
|
||||||
|
//
|
||||||
|
// this.recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(CastingRecipe recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.output);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void removeTableRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
|
||||||
|
// removeRecipe(output, material, cast, TConstructHelper.tableCasting);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
|
||||||
|
//
|
||||||
|
// removeRecipe(output, material, cast, TConstructHelper.basinCasting);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, List<CastingRecipe> list) {
|
||||||
|
// if(output == null) {
|
||||||
|
// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(material == null) {
|
||||||
|
// material = IngredientAny.INSTANCE;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(cast == null) {
|
||||||
|
// cast = IngredientAny.INSTANCE;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// List<CastingRecipe> recipes = new LinkedList<CastingRecipe>();
|
||||||
|
//
|
||||||
|
// for(CastingRecipe recipe : list) {
|
||||||
|
// if(recipe != null) {
|
||||||
|
// if (!matches(output, toIItemStack(recipe.output))) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!matches(material, toILiquidStack(recipe.castingMetal))) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!matches(cast, toIItemStack(recipe.cast))) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new Remove(list, recipes));
|
||||||
|
// } else {
|
||||||
|
// LogHelper.logWarning(String.format("No %s Recipe found for output %s, material %s and cast %s. Command ignored!", Casting.name, output.toString(), material.toString(), cast.toString()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Removes all matching recipes, apply is never the same for anything, so will always need to override it
|
||||||
|
// private static class Remove extends BaseListRemoval<CastingRecipe> {
|
||||||
|
// public Remove(List<CastingRecipe> list, List<CastingRecipe> recipes) {
|
||||||
|
// super(Casting.name, list, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(CastingRecipe recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.output);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,82 @@
|
||||||
|
//package modtweaker2.mods.tconstruct.handlers;
|
||||||
|
//
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
|
//
|
||||||
|
//import java.util.LinkedList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//import minetweaker.MineTweakerAPI;
|
||||||
|
//import minetweaker.api.item.IIngredient;
|
||||||
|
//import minetweaker.api.item.IItemStack;
|
||||||
|
//import modtweaker2.helpers.LogHelper;
|
||||||
|
//import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
//import modtweaker2.utils.BaseListAddition;
|
||||||
|
//import modtweaker2.utils.BaseListRemoval;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
//import tconstruct.library.crafting.DryingRackRecipes;
|
||||||
|
//import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
|
||||||
|
//
|
||||||
|
//@ZenClass("mods.tconstruct.Drying")
|
||||||
|
//public class Drying {
|
||||||
|
//
|
||||||
|
// protected static final String name = "TConstruct Drying Rack";
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void addRecipe(IItemStack input, IItemStack output, int time) {
|
||||||
|
// if(input == null || output == null) {
|
||||||
|
// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output))));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //Passes the list to the base list implementation, and adds the recipe
|
||||||
|
// private static class Add extends BaseListAddition<DryingRecipe> {
|
||||||
|
// public Add(DryingRecipe recipe) {
|
||||||
|
// super(Drying.name, DryingRackRecipes.recipes);
|
||||||
|
// this.recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(DryingRecipe recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.result);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// //Removing a TConstruct Drying Rack recipe
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void removeRecipe(IIngredient ingredient) {
|
||||||
|
// List<DryingRecipe> recipes = new LinkedList<DryingRecipe>();
|
||||||
|
//
|
||||||
|
// for (DryingRecipe recipe : DryingRackRecipes.recipes) {
|
||||||
|
// if (recipe != null && recipe.result != null && ingredient.matches(toIItemStack(recipe.result))) {
|
||||||
|
// recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
// } else {
|
||||||
|
// LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //Removes a recipe, apply is never the same for anything, so will always need to override it
|
||||||
|
// private static class Remove extends BaseListRemoval<DryingRecipe> {
|
||||||
|
// public Remove(List<DryingRecipe> list) {
|
||||||
|
// super(Drying.name, DryingRackRecipes.recipes, list);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(DryingRecipe recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.result);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,48 @@
|
||||||
|
//package modtweaker2.mods.tconstruct.handlers;
|
||||||
|
//
|
||||||
|
//import java.util.LinkedList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//import minetweaker.MineTweakerAPI;
|
||||||
|
//import modtweaker2.helpers.LogHelper;
|
||||||
|
//import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
//import modtweaker2.utils.BaseListRemoval;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
//import tconstruct.library.modifier.ItemModifier;
|
||||||
|
//
|
||||||
|
//@ZenClass("mods.tconstruct.Modifiers")
|
||||||
|
//public class Modifiers {
|
||||||
|
//
|
||||||
|
// protected static final String name = "TConstruct Modifier";
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void remove(String mod) {
|
||||||
|
// List<ItemModifier> recipes = new LinkedList<ItemModifier>();
|
||||||
|
//
|
||||||
|
// for (ItemModifier recipe : TConstructHelper.modifiers) {
|
||||||
|
// if (recipe.key.equals(mod)) {
|
||||||
|
// recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
// } else {
|
||||||
|
// LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Modifiers.name, mod));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static class Remove extends BaseListRemoval<ItemModifier>{
|
||||||
|
// public Remove(List<ItemModifier> recipes) {
|
||||||
|
// super(Modifiers.name, TConstructHelper.modifiers, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(ItemModifier recipe) {
|
||||||
|
// return recipe.key;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
298
src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java
Normal file
298
src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java
Normal file
|
@ -0,0 +1,298 @@
|
||||||
|
//package modtweaker2.mods.tconstruct.handlers;
|
||||||
|
//
|
||||||
|
//import static modtweaker2.helpers.InputHelper.isABlock;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toFluid;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toFluids;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
|
//import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
//
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.Arrays;
|
||||||
|
//import java.util.HashMap;
|
||||||
|
//import java.util.LinkedList;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.Map;
|
||||||
|
//import java.util.Map.Entry;
|
||||||
|
//
|
||||||
|
//import minetweaker.MineTweakerAPI;
|
||||||
|
//import minetweaker.api.item.IIngredient;
|
||||||
|
//import minetweaker.api.item.IItemStack;
|
||||||
|
//import minetweaker.api.liquid.ILiquidStack;
|
||||||
|
//import modtweaker2.helpers.LogHelper;
|
||||||
|
//import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
//import modtweaker2.utils.BaseListAddition;
|
||||||
|
//import modtweaker2.utils.BaseListRemoval;
|
||||||
|
//import modtweaker2.utils.BaseMapAddition;
|
||||||
|
//import modtweaker2.utils.BaseMapRemoval;
|
||||||
|
//import net.minecraft.block.Block;
|
||||||
|
//import net.minecraft.item.ItemStack;
|
||||||
|
//import net.minecraftforge.fluids.Fluid;
|
||||||
|
//import net.minecraftforge.fluids.FluidStack;
|
||||||
|
//import stanhebben.zenscript.annotations.Optional;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
//
|
||||||
|
//@ZenClass("mods.tconstruct.Smeltery")
|
||||||
|
//public class Smeltery {
|
||||||
|
//
|
||||||
|
// public static final String nameFuel = "TConstruct Smeltery - Fuel";
|
||||||
|
// public static final String nameMelting = "TConstruct Smeltery - Melting";
|
||||||
|
// public static final String nameAlloy = "TConstruct Smeltery - Alloy";
|
||||||
|
//
|
||||||
|
// /********************************************** TConstruct Alloy Recipes **********************************************/
|
||||||
|
//
|
||||||
|
// // Adding a TConstruct Alloy recipe
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void addAlloy(ILiquidStack output, ILiquidStack[] input) {
|
||||||
|
// if(input == null || output == null) {
|
||||||
|
// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameAlloy));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// MineTweakerAPI.apply(new AddAlloy(new AlloyMix(toFluid(output), new ArrayList<FluidStack>(Arrays.asList(toFluids(input))))));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Passes the list to the base list implementation, and adds the recipe
|
||||||
|
// private static class AddAlloy extends BaseListAddition<AlloyMix> {
|
||||||
|
// public AddAlloy(AlloyMix recipe) {
|
||||||
|
// super("TConstruct Smeltery - Alloy", TConstructHelper.alloys);
|
||||||
|
// this.recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(AlloyMix recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.result);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// // Removing a TConstruct Alloy recipe
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void removeAlloy(IIngredient output) {
|
||||||
|
// List<AlloyMix> recipes = new LinkedList<AlloyMix>();
|
||||||
|
//
|
||||||
|
// for(AlloyMix r : TConstructHelper.alloys) {
|
||||||
|
// if(r != null && matches(output, toILiquidStack(r.result))) {
|
||||||
|
// recipes.add(r);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new RemoveAlloy(recipes));
|
||||||
|
// } else {
|
||||||
|
// LogHelper.logError(String.format("No %s recipes found for %s. Command ignored!", nameAlloy, output.toString()));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Removes a recipe, apply is never the same for anything, so will always
|
||||||
|
// // need to override it
|
||||||
|
// private static class RemoveAlloy extends BaseListRemoval<AlloyMix> {
|
||||||
|
// public RemoveAlloy(List<AlloyMix> recipes) {
|
||||||
|
// super(nameAlloy, TConstructHelper.alloys, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(AlloyMix recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.result);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /********************************************** TConstruct Melting Recipes **********************************************/
|
||||||
|
//
|
||||||
|
// // Adding a TConstruct Melting recipe
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) {
|
||||||
|
//
|
||||||
|
// if(input == null || output == null) {
|
||||||
|
// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameMelting));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
|
||||||
|
//
|
||||||
|
// for(IItemStack in : input.getItems()) {
|
||||||
|
// if(block == null && !isABlock(toStack(in))) {
|
||||||
|
// LogHelper.logWarning(String.format("Item %s is not a block and no block renderer is provided for %s recipe. Input ignored!", in.toString(), nameMelting));
|
||||||
|
// } else {
|
||||||
|
// recipes.add(new MeltingRecipe(toStack(in), toFluid(output), temp, block == null ? toStack(in) : toStack(block)));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new AddMelting(recipes));
|
||||||
|
// } else {
|
||||||
|
// LogHelper.logError(String.format("No %s recipes could be added for input %s.", nameMelting, input.toString()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static class AddMelting extends BaseListAddition<MeltingRecipe> {
|
||||||
|
//
|
||||||
|
// public AddMelting(List<MeltingRecipe> recipes) {
|
||||||
|
// super(nameMelting, null, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void apply() {
|
||||||
|
// for(MeltingRecipe recipe : recipes) {
|
||||||
|
// tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid);
|
||||||
|
// successful.add(recipe);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void undo() {
|
||||||
|
// for(MeltingRecipe recipe : successful) {
|
||||||
|
// TConstructHelper.smeltingList.remove(recipe.meta);
|
||||||
|
// TConstructHelper.temperatureList.remove(recipe.meta);
|
||||||
|
// TConstructHelper.renderIndex.remove(recipe.meta);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getRecipeInfo(MeltingRecipe recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.input);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// // Removing a TConstruct Melting recipe
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void removeMelting(IIngredient input) {
|
||||||
|
// List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
|
||||||
|
//
|
||||||
|
// for(ItemMetaWrapper meta : TConstructHelper.smeltingList.keySet()) {
|
||||||
|
// ItemStack in = new ItemStack(meta.item, 1, meta.meta);
|
||||||
|
// if(matches(input, toIItemStack(in))) {
|
||||||
|
// recipes.add(new MeltingRecipe(
|
||||||
|
// in,
|
||||||
|
// TConstructHelper.smeltingList.get(meta),
|
||||||
|
// TConstructHelper.temperatureList.get(meta),
|
||||||
|
// TConstructHelper.renderIndex.get(meta)));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new RemoveMelting(recipes));
|
||||||
|
// } else {
|
||||||
|
// LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static class RemoveMelting extends BaseListRemoval<MeltingRecipe> {
|
||||||
|
//
|
||||||
|
// public RemoveMelting(List<MeltingRecipe> recipes) {
|
||||||
|
// super(nameMelting, null, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void apply() {
|
||||||
|
// for(MeltingRecipe recipe : recipes) {
|
||||||
|
// TConstructHelper.smeltingList.remove(recipe.meta);
|
||||||
|
// TConstructHelper.temperatureList.remove(recipe.meta);
|
||||||
|
// TConstructHelper.renderIndex.remove(recipe.meta);
|
||||||
|
//
|
||||||
|
// successful.add(recipe);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void undo() {
|
||||||
|
// for(MeltingRecipe recipe : successful) {
|
||||||
|
// tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getRecipeInfo(MeltingRecipe recipe) {
|
||||||
|
// return LogHelper.getStackDescription(recipe.input);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// protected static class MeltingRecipe {
|
||||||
|
// public final ItemMetaWrapper meta;
|
||||||
|
// public final ItemStack input;
|
||||||
|
// public final FluidStack fluid;
|
||||||
|
// public final Integer temperature;
|
||||||
|
// public final ItemStack renderer;
|
||||||
|
//
|
||||||
|
// protected MeltingRecipe(ItemStack input, FluidStack fluid, int temperature, ItemStack renderer) {
|
||||||
|
// this.input = input;
|
||||||
|
// this.fluid = fluid;
|
||||||
|
// this.temperature = temperature;
|
||||||
|
// this.renderer = renderer;
|
||||||
|
// this.meta = new ItemMetaWrapper(input);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public Block getRendererBlock() {
|
||||||
|
// return Block.getBlockFromItem(renderer.getItem());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public int getRendererMeta() {
|
||||||
|
// return renderer.getItemDamage();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /********************************************** TConstruct Fuel Recipes **********************************************/
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void removeFuel(IIngredient input) {
|
||||||
|
// Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||||
|
//
|
||||||
|
// for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
|
||||||
|
// if(fuel != null && fuel.getKey() != null && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) {
|
||||||
|
// recipes.put(fuel.getKey(), fuel.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new RemoveFuel(recipes));
|
||||||
|
// } else {
|
||||||
|
// LogHelper.logWarning(String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static class RemoveFuel extends BaseMapRemoval<Fluid, Integer[]> {
|
||||||
|
// public RemoveFuel(Map<Fluid, Integer[]> recipes) {
|
||||||
|
// super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
|
||||||
|
// return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void addFuel(ILiquidStack liquid, int power, int duration) {
|
||||||
|
// if(liquid == null) {
|
||||||
|
// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||||
|
//
|
||||||
|
// recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration});
|
||||||
|
//
|
||||||
|
// MineTweakerAPI.apply(new AddFuel(recipes));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static class AddFuel extends BaseMapAddition<Fluid, Integer[]> {
|
||||||
|
// public AddFuel(Map<Fluid, Integer[]> recipes) {
|
||||||
|
// super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
|
||||||
|
// return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,118 @@
|
||||||
|
//package modtweaker2.mods.tconstruct.handlers;
|
||||||
|
//
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
|
//import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
|
//
|
||||||
|
//import java.util.LinkedList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//import minetweaker.MineTweakerAPI;
|
||||||
|
//import minetweaker.api.item.IIngredient;
|
||||||
|
//import minetweaker.api.item.IItemStack;
|
||||||
|
//import modtweaker2.helpers.LogHelper;
|
||||||
|
//import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
//import modtweaker2.utils.BaseListAddition;
|
||||||
|
//import modtweaker2.utils.BaseListRemoval;
|
||||||
|
//import net.minecraft.item.ItemStack;
|
||||||
|
//import stanhebben.zenscript.annotations.Optional;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
//import tconstruct.library.crafting.PatternBuilder;
|
||||||
|
//import tconstruct.library.crafting.PatternBuilder.ItemKey;
|
||||||
|
//
|
||||||
|
//@ZenClass("mods.tconstruct.Tweaks")
|
||||||
|
//public class TiCTweaks {
|
||||||
|
//
|
||||||
|
// // //////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// /** Disabling for 0.5, will do this properly for 0.6 **/
|
||||||
|
// // Tweaks for enabling / disabling Patterns
|
||||||
|
// /*
|
||||||
|
// * @ZenMethod public static void removePattern(IItemStack stack) {
|
||||||
|
// * MineTweakerAPI.apply(new DisablePattern(toStack(stack))); }
|
||||||
|
// *
|
||||||
|
// * private static class DisablePattern implements IUndoableAction { private
|
||||||
|
// * String key; private MaterialSet set; private List list; private ItemStack
|
||||||
|
// * stack; private final ItemStack disable;
|
||||||
|
// *
|
||||||
|
// * public DisablePattern(ItemStack disable) { this.disable = disable; }
|
||||||
|
// *
|
||||||
|
// * //Loops through the pattern mappings to find an entry with the same
|
||||||
|
// * material name
|
||||||
|
// *
|
||||||
|
// * @Override public void apply() { for (Entry<List, ItemStack> entry :
|
||||||
|
// * TConstructRegistry.patternPartMapping.entrySet()) { ItemStack check =
|
||||||
|
// * entry.getValue(); if (check.isItemEqual(disable)) { list =
|
||||||
|
// * entry.getKey(); stack = entry.getValue(); break; } }
|
||||||
|
// *
|
||||||
|
// * TConstructRegistry.patternPartMapping.remove(list); }
|
||||||
|
// *
|
||||||
|
// * @Override public boolean canUndo() { return true; }
|
||||||
|
// *
|
||||||
|
// * @Override public void undo() {
|
||||||
|
// * TConstructRegistry.patternPartMapping.put(list, stack); }
|
||||||
|
// *
|
||||||
|
// * @Override public String describe() { return
|
||||||
|
// * "Disabling creation of the pattern for: " + disable.getDisplayName(); }
|
||||||
|
// *
|
||||||
|
// * @Override public String describeUndo() { return
|
||||||
|
// * "Enabling creation of the pattern for: " + disable.getDisplayName(); }
|
||||||
|
// *
|
||||||
|
// * @Override public Object getOverrideKey() { return null; } }
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// // //////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void addRepairMaterial(IItemStack stack, String material, int value) {
|
||||||
|
// ItemStack input = toStack(stack);
|
||||||
|
// MineTweakerAPI.apply(new Add(PatternBuilder.instance.new ItemKey(input.getItem(), input.getItemDamage(), value, material)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Tweaks for setting repair materials
|
||||||
|
// private static class Add extends BaseListAddition<ItemKey> {
|
||||||
|
// public Add(ItemKey recipe) {
|
||||||
|
// super("Repair Material", PatternBuilder.instance.materials);
|
||||||
|
// recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(ItemKey recipe) {
|
||||||
|
// return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void removeRepairMaterial(IIngredient output, @Optional String material) {
|
||||||
|
//
|
||||||
|
// List<ItemKey> recipes = new LinkedList<ItemKey>();
|
||||||
|
//
|
||||||
|
// for (ItemKey recipe : PatternBuilder.instance.materials) {
|
||||||
|
// IItemStack clone = toIItemStack(new ItemStack(recipe.item, 1, recipe.damage));
|
||||||
|
// if ((material != null && material.equalsIgnoreCase(recipe.key)) || (material == null)) {
|
||||||
|
// if (output.matches(clone)) {
|
||||||
|
// recipes.add(recipe);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(!recipes.isEmpty()) {
|
||||||
|
// MineTweakerAPI.apply(new Remove(recipes));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Removes a recipe, apply is never the same for anything, so will always
|
||||||
|
// // need to override it
|
||||||
|
// private static class Remove extends BaseListRemoval<ItemKey> {
|
||||||
|
// public Remove(List<ItemKey> recipes) {
|
||||||
|
// super("Repair Material", PatternBuilder.instance.materials, recipes);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected String getRecipeInfo(ItemKey recipe) {
|
||||||
|
// return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,270 @@
|
||||||
|
//package modtweaker2.mods.tconstruct.handlers;
|
||||||
|
//
|
||||||
|
//import minetweaker.IUndoableAction;
|
||||||
|
//import minetweaker.MineTweakerAPI;
|
||||||
|
//import modtweaker2.helpers.ReflectionHelper;
|
||||||
|
//import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||||
|
//import slimeknights.tconstruct.library.TinkerRegistry;
|
||||||
|
//import slimeknights.tconstruct.library.materials.Material;
|
||||||
|
//import slimeknights.tconstruct.tools.TinkerMaterials;
|
||||||
|
//import stanhebben.zenscript.annotations.Optional;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
//import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
//import tconstruct.library.TConstructRegistry;
|
||||||
|
//import tconstruct.library.tools.ArrowMaterial;
|
||||||
|
//import tconstruct.library.tools.BowMaterial;
|
||||||
|
//import tconstruct.library.tools.ToolMaterial;
|
||||||
|
//
|
||||||
|
//@ZenClass("mods.tconstruct.ToolStats")
|
||||||
|
//public class ToolStats {
|
||||||
|
// /**
|
||||||
|
// * @deprecated
|
||||||
|
// */
|
||||||
|
// @Deprecated
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, String ability) {
|
||||||
|
// if (name == null) name = material + " ";
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "", new Material(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, 0xFFFFFF)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @deprecated
|
||||||
|
// */
|
||||||
|
// @Deprecated
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) {
|
||||||
|
// if (name == null) name = material + " ";
|
||||||
|
// Material m;
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setStats(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) {
|
||||||
|
// if (name == null) name = material + " ";
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setDisplayName(String material, String name) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "displayName", name));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setHarvestLevel(String material, int value) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "harvestLevel", value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setDurability(String material, int value) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "durability", value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setSpeed(String material, int value) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "miningspeed", value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setDamage(String material, int value) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "attack", value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setHandleModifier(String material, double value) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "handleModifier", (float) value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setReinforcedLevel(String material, int value) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "reinforced", value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setStoneboundLevel(String material, double value) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "stonebound", (float) value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setStyle(String material, String name) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "tipStyle", name));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setAbility(String material, String name) {
|
||||||
|
// MineTweakerAPI.apply(new SetToolStats(material, "ability", name));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //Sets various variables with reflection, making my life partially easier :D
|
||||||
|
// private static class SetToolStats implements IUndoableAction {
|
||||||
|
// protected int id;
|
||||||
|
// protected Object old;
|
||||||
|
// protected Object fresh;
|
||||||
|
// protected final String material;
|
||||||
|
// protected final String field;
|
||||||
|
// protected final Object value;
|
||||||
|
//
|
||||||
|
// public SetToolStats(String material, String field, Object value) {
|
||||||
|
// this.material = material;
|
||||||
|
// this.field = field;
|
||||||
|
// this.value = value;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void apply() {
|
||||||
|
// old = TConstructRegistry.toolMaterialStrings.get(material);
|
||||||
|
// id = TConstructHelper.getIDFromString(material);
|
||||||
|
// if (id != -1 && old != null) {
|
||||||
|
// if (value instanceof ToolMaterial) {
|
||||||
|
// fresh = (ToolMaterial) value;
|
||||||
|
// } else {
|
||||||
|
// ToolMaterial t = (ToolMaterial) old;
|
||||||
|
// fresh = new ToolMaterial(t.materialName, t.localizationString, t.harvestLevel, t.durability, t.miningspeed, t.attack, t.handleModifier, t.reinforced, t.stonebound, t.tipStyle, t.primaryColor);
|
||||||
|
// ReflectionHelper.setPrivateValue(ToolMaterial.class, fresh, field, value);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TConstructRegistry.toolMaterials.put(id, (ToolMaterial) fresh);
|
||||||
|
// TConstructRegistry.toolMaterialStrings.put(material, (ToolMaterial) fresh);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean canUndo() {
|
||||||
|
// return TConstructRegistry.toolMaterialStrings != null && id != -1 && old != null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void undo() {
|
||||||
|
// TConstructRegistry.toolMaterials.put(id, (ToolMaterial) old);
|
||||||
|
// TConstructRegistry.toolMaterialStrings.put(material, (ToolMaterial) old);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String describe() {
|
||||||
|
// return "Changing material stats field : + " + field + " for " + material;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String describeUndo() {
|
||||||
|
// return "Undoing change of material stats field : + " + field + " for " + material;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public Object getOverrideKey() {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// //Bow Stats
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setBowStats(String material, int durability, int drawspeed, double flightspeed) {
|
||||||
|
// MineTweakerAPI.apply(new SetBowStats(material, "", new BowMaterial(durability, drawspeed, (float) flightspeed)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setBowDurability(String material, int value) {
|
||||||
|
// MineTweakerAPI.apply(new SetBowStats(material, "durability", value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setBowDrawspeed(String material, int value) {
|
||||||
|
// MineTweakerAPI.apply(new SetBowStats(material, "drawspeed", value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setBowFlightSpeed(String material, double value) {
|
||||||
|
// MineTweakerAPI.apply(new SetBowStats(material, "flightSpeedMax", (float) value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Bow Stats
|
||||||
|
// private static class SetBowStats extends SetToolStats {
|
||||||
|
// public SetBowStats(String material, String field, Object value) {
|
||||||
|
// super(material, field, value);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void apply() {
|
||||||
|
// id = TConstructHelper.getIDFromString(material);
|
||||||
|
// old = TConstructRegistry.bowMaterials.get(id);
|
||||||
|
// if (id != -1 && old != null) {
|
||||||
|
// if (value instanceof BowMaterial) {
|
||||||
|
// fresh = (BowMaterial) value;
|
||||||
|
// } else {
|
||||||
|
// BowMaterial b = (BowMaterial) old;
|
||||||
|
// fresh = new BowMaterial(b.durability, b.drawspeed, b.flightSpeedMax);
|
||||||
|
// ReflectionHelper.setPrivateValue(BowMaterial.class, fresh, field, value);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TConstructRegistry.bowMaterials.put(id, (BowMaterial) fresh);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean canUndo() {
|
||||||
|
// return TConstructRegistry.bowMaterials != null && id != -1 && old != null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void undo() {
|
||||||
|
// TConstructRegistry.bowMaterials.put(id, (BowMaterial) old);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// //Arrow Stats
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setArrowStats(String material, double mass, double breakChance, double accuracy) {
|
||||||
|
// MineTweakerAPI.apply(new SetArrowStats(material, "", new ArrowMaterial((float) mass, (float) breakChance, (float) accuracy)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setArrowMass(String material, double value) {
|
||||||
|
// MineTweakerAPI.apply(new SetArrowStats(material, "mass", (float) value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setArrowBreakChance(String material, double value) {
|
||||||
|
// MineTweakerAPI.apply(new SetArrowStats(material, "breakChance", (float) value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @ZenMethod
|
||||||
|
// public static void setArrowAccuracy(String material, double value) {
|
||||||
|
// MineTweakerAPI.apply(new SetArrowStats(material, "accuracy", (float) value));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Bow Stats
|
||||||
|
// private static class SetArrowStats extends SetToolStats {
|
||||||
|
// public SetArrowStats(String material, String field, Object value) {
|
||||||
|
// super(material, field, value);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void apply() {
|
||||||
|
// id = TConstructHelper.getIDFromString(material);
|
||||||
|
// old = TConstructRegistry.arrowMaterials.get(id);
|
||||||
|
// if (id != -1 && old != null) {
|
||||||
|
// if (value instanceof ArrowMaterial) {
|
||||||
|
// fresh = (ArrowMaterial) value;
|
||||||
|
// } else {
|
||||||
|
// ArrowMaterial a = (ArrowMaterial) old;
|
||||||
|
// fresh = new ArrowMaterial(a.mass, a.breakChance, a.accuracy);
|
||||||
|
// ReflectionHelper.setPrivateValue(ArrowMaterial.class, fresh, field, value);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TConstructRegistry.arrowMaterials.put(id, (ArrowMaterial) fresh);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean canUndo() {
|
||||||
|
// return TConstructRegistry.arrowMaterials != null && id != -1 && old != null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void undo() {
|
||||||
|
// TConstructRegistry.arrowMaterials.put(id, (ArrowMaterial) old);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -1,24 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import modtweaker2.mods.thaumcraft.aspect.AspectBracketHandler;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Arcane;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Aspects;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Crucible;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Infusion;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Loot;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Research;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Warp;
|
|
||||||
|
|
||||||
public class Thaumcraft {
|
|
||||||
public Thaumcraft() {
|
|
||||||
MineTweakerAPI.registerBracketHandler(new AspectBracketHandler());
|
|
||||||
MineTweakerAPI.registerClass(Arcane.class);
|
|
||||||
MineTweakerAPI.registerClass(Aspects.class);
|
|
||||||
MineTweakerAPI.registerClass(Crucible.class);
|
|
||||||
MineTweakerAPI.registerClass(Infusion.class);
|
|
||||||
MineTweakerAPI.registerClass(Research.class);
|
|
||||||
MineTweakerAPI.registerClass(Warp.class);
|
|
||||||
MineTweakerAPI.registerClass(Loot.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,135 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import modtweaker2.helpers.LogHelper;
|
|
||||||
import modtweaker2.helpers.ReflectionHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.aspect.AspectStack;
|
|
||||||
import modtweaker2.mods.thaumcraft.aspect.IAspectStack;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
import thaumcraft.api.ThaumcraftApi.EntityTags;
|
|
||||||
import thaumcraft.api.aspects.Aspect;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class ThaumcraftHelper {
|
|
||||||
public static HashMap<Object, Integer> warpList;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
warpList = ReflectionHelper.getStaticObject(ThaumcraftApi.class, "warpMap");
|
|
||||||
} catch (Exception e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ThaumcraftHelper() {}
|
|
||||||
|
|
||||||
public static AspectList parseAspects(String aspects) {
|
|
||||||
return parseAspects(new AspectList(), aspects);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AspectList parseAspects(AspectList list, String str) {
|
|
||||||
AspectList output=new AspectList();
|
|
||||||
if (list != null)
|
|
||||||
for(Aspect aspect : list.getAspectsSortedByAmount())
|
|
||||||
{
|
|
||||||
if(aspect!=null)
|
|
||||||
output.add(aspect, list.getAmount(aspect));
|
|
||||||
}
|
|
||||||
if (str == null || str.equals("")) return list;
|
|
||||||
String[] aspects = str.split(",");
|
|
||||||
for (String aspect : aspects) {
|
|
||||||
if (aspect.startsWith(" ")) aspect = aspect.replaceFirst(" ", "");
|
|
||||||
String[] aspct = aspect.split("\\s+");
|
|
||||||
if (aspct.length == 2) output.add(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AspectList removeAspects(AspectList list, String str) {
|
|
||||||
AspectList output=new AspectList();
|
|
||||||
if (list != null)
|
|
||||||
for(Aspect aspect : list.getAspectsSortedByAmount())
|
|
||||||
{
|
|
||||||
if(aspect!=null)
|
|
||||||
output.add(aspect, list.getAmount(aspect));
|
|
||||||
}
|
|
||||||
String[] aspects = str.split(",");
|
|
||||||
for (String aspect : aspects) {
|
|
||||||
if (aspect.startsWith(" ")) aspect = aspect.replaceFirst(" ", "");
|
|
||||||
String[] aspct = aspect.split("\\s+");
|
|
||||||
if (aspct.length == 2) {
|
|
||||||
output.remove(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getResearchTab(String key) {
|
|
||||||
for (String tab : ResearchCategories.researchCategories.keySet()) {
|
|
||||||
for (String research : ResearchCategories.researchCategories.get(tab).research.keySet()) {
|
|
||||||
if (research.equals(key)) return tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AspectList getEntityAspects(String name) {
|
|
||||||
for(EntityTags tag : ThaumcraftApi.scanEntities)
|
|
||||||
{
|
|
||||||
if(tag.entityName==name && tag.nbts.length==0)
|
|
||||||
return tag.aspects;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeEntityAspects(String name) {
|
|
||||||
List<EntityTags> tags = new ArrayList(ThaumcraftApi.scanEntities);
|
|
||||||
for(EntityTags tag : tags)
|
|
||||||
{
|
|
||||||
if(tag.entityName==name && tag.nbts.length==0)
|
|
||||||
ThaumcraftApi.scanEntities.remove(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String aspectsToString(AspectList aspects)
|
|
||||||
{
|
|
||||||
System.out.println(aspects);
|
|
||||||
String output="";
|
|
||||||
for(Aspect aspect : aspects.getAspectsSortedByAmount())
|
|
||||||
{
|
|
||||||
if(aspect!=null)
|
|
||||||
output+=aspect.getName()+" "+aspects.getAmount(aspect)+",";
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AspectStack[] toStacks(IAspectStack[] iStack) {
|
|
||||||
if (iStack == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
AspectStack[] output = new AspectStack[iStack.length];
|
|
||||||
for (int i = 0; i < iStack.length; i++) {
|
|
||||||
output[i] = toStack(iStack[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AspectStack toStack(IAspectStack iStack) {
|
|
||||||
if (iStack == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
Object internal = iStack.getInternal();
|
|
||||||
if (!(internal instanceof AspectStack)) {
|
|
||||||
LogHelper.logError("Not a valid aspect stack: " + iStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (AspectStack) internal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.aspect;
|
|
||||||
|
|
||||||
import thaumcraft.api.aspects.Aspect;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
|
||||||
|
|
||||||
public class AspectStack {
|
|
||||||
public Aspect aspect;
|
|
||||||
public int amount;
|
|
||||||
|
|
||||||
public AspectStack(Aspect aspect, int amount) {
|
|
||||||
this.aspect = aspect;
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Aspect getAspect() {
|
|
||||||
return aspect;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AspectList getAspectList() {
|
|
||||||
AspectList aspectList = new AspectList();
|
|
||||||
aspectList.add(aspect, amount);
|
|
||||||
return aspectList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AspectList join(AspectList... aspectLists) {
|
|
||||||
AspectList result = new AspectList();
|
|
||||||
|
|
||||||
for(AspectList aspectList : aspectLists) {
|
|
||||||
result.add(aspectList);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AspectList join(AspectStack... aspectStacks) {
|
|
||||||
AspectList result = new AspectList();
|
|
||||||
|
|
||||||
for(AspectStack stack : aspectStacks) {
|
|
||||||
result.add(stack.getAspectList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.aspect;
|
|
||||||
|
|
||||||
public interface IAspectDefinition {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.aspect;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import stanhebben.zenscript.annotations.OperatorType;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenGetter;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import stanhebben.zenscript.annotations.ZenOperator;
|
|
||||||
|
|
||||||
@ZenClass("modtweaker.aspect.IAspectStack")
|
|
||||||
public interface IAspectStack extends IIngredient {
|
|
||||||
|
|
||||||
@ZenGetter("definition")
|
|
||||||
public abstract IAspectDefinition getDefinition();
|
|
||||||
|
|
||||||
@ZenGetter("name")
|
|
||||||
public abstract String getName();
|
|
||||||
|
|
||||||
@ZenGetter("displayName")
|
|
||||||
public abstract String getDisplayName();
|
|
||||||
|
|
||||||
@ZenOperator(OperatorType.MUL)
|
|
||||||
@ZenMethod
|
|
||||||
public abstract IAspectStack amount(int amount);
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public abstract IAspectStack withAmount(int amount);
|
|
||||||
|
|
||||||
public abstract List<IAspectStack> getAspects();
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.aspect;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class MCAspectDefinition implements IAspectDefinition {
|
|
||||||
|
|
||||||
public MCAspectDefinition(AspectStack stack) {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,183 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.aspect;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemCondition;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.item.IItemTransformer;
|
|
||||||
import minetweaker.api.item.IngredientOr;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
|
||||||
|
|
||||||
|
|
||||||
public class MCAspectStack implements IAspectStack {
|
|
||||||
|
|
||||||
private final AspectStack stack;
|
|
||||||
private final List<IAspectStack> aspects;
|
|
||||||
|
|
||||||
public MCAspectStack(AspectStack stack) {
|
|
||||||
if(stack == null) throw new IllegalArgumentException("stack cannot be null");
|
|
||||||
|
|
||||||
this.stack = stack;
|
|
||||||
this.aspects = Collections.<IAspectStack>singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack applyTransform(IItemStack arg0, IPlayer arg1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(IIngredient ingredient) {
|
|
||||||
if(ingredient instanceof MCAspectStack) {
|
|
||||||
List<IAspectStack> aspects = ((MCAspectStack)ingredient).getAspects();
|
|
||||||
|
|
||||||
if((aspects == null) || (aspects.size() != 1)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return matches(aspects.get(0));
|
|
||||||
} else {
|
|
||||||
List<IItemStack> iitems = ingredient.getItems();
|
|
||||||
if ((iitems == null) || (iitems.size() != 1)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return matches((IItemStack)iitems.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAmount() {
|
|
||||||
return this.stack.amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getInternal() {
|
|
||||||
return this.stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getItems() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IAspectStack> getAspects() {
|
|
||||||
return this.aspects;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ILiquidStack> getLiquids() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMark() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTransformers() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient marked(String arg0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IItemStack item) {
|
|
||||||
ItemStack internal = MineTweakerMC.getItemStack(item);
|
|
||||||
|
|
||||||
if(internal != null) {
|
|
||||||
AspectList itemAspectList = new AspectList(internal);
|
|
||||||
|
|
||||||
if(itemAspectList.aspects.keySet().contains(stack.aspect.getTag())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean matches(IAspectStack aspect) {
|
|
||||||
if(aspect != null) {
|
|
||||||
Object internal = aspect.getInternal();
|
|
||||||
|
|
||||||
if(internal != null && internal instanceof AspectStack) {
|
|
||||||
if(this.stack.aspect.getTag().equals(((AspectStack)internal).aspect.getTag())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(ILiquidStack arg0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient only(IItemCondition arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient or(IIngredient ingredient) {
|
|
||||||
return new IngredientOr(this, ingredient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient transform(IItemTransformer arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IAspectDefinition getDefinition() {
|
|
||||||
return new MCAspectDefinition(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return this.stack.aspect.getTag();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return this.stack.aspect.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IAspectStack amount(int amount) {
|
|
||||||
return withAmount(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IAspectStack withAmount(int amount) {
|
|
||||||
AspectStack result = new AspectStack(this.stack.aspect, amount);
|
|
||||||
return new MCAspectStack(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append("<aspect:").append(stack.aspect.getName()).append('>');
|
|
||||||
|
|
||||||
if(stack.amount > 1) {
|
|
||||||
sb.append(" * ").append(stack.amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.commands;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.server.ICommandFunction;
|
|
||||||
import thaumcraft.api.aspects.Aspect;
|
|
||||||
|
|
||||||
public class AspectLogger implements ICommandFunction{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
|
|
||||||
for(Aspect aspect : Aspect.getPrimalAspects()) {
|
|
||||||
MineTweakerAPI.logCommand("<aspect:" + aspect.getName() + "> // " + aspect.getLocalizedDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Aspect aspect : Aspect.getCompoundAspects()) {
|
|
||||||
MineTweakerAPI.logCommand("<aspect:" + aspect.getName() + "> // " + aspect.getLocalizedDescription() + " [<aspect:" + aspect.getComponents()[0].getName() + ">, <aspect:" + aspect.getComponents()[1].getName() + ">]");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.handlers;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
|
||||||
import static modtweaker2.helpers.InputHelper.toObjects;
|
|
||||||
import static modtweaker2.helpers.InputHelper.toShapedObjects;
|
|
||||||
import static modtweaker2.helpers.InputHelper.toStack;
|
|
||||||
import static modtweaker2.helpers.StackHelper.matches;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import modtweaker2.helpers.LogHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import modtweaker2.utils.BaseListAddition;
|
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
import thaumcraft.api.crafting.IArcaneRecipe;
|
|
||||||
import thaumcraft.api.crafting.ShapedArcaneRecipe;
|
|
||||||
import thaumcraft.api.crafting.ShapelessArcaneRecipe;
|
|
||||||
|
|
||||||
@ZenClass("mods.thaumcraft.Arcane")
|
|
||||||
public class Arcane {
|
|
||||||
|
|
||||||
public static final String name = "Thaumcraft Arcane Worktable";
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) {
|
|
||||||
MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients))));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) {
|
|
||||||
MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients))));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Add extends BaseListAddition<IArcaneRecipe> {
|
|
||||||
public Add(IArcaneRecipe recipe) {
|
|
||||||
super(Arcane.name, ThaumcraftApi.getCraftingRecipes());
|
|
||||||
recipes.add(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(IArcaneRecipe recipe) {
|
|
||||||
ItemStack stack = recipe.getRecipeOutput();
|
|
||||||
|
|
||||||
if(stack instanceof ItemStack)
|
|
||||||
return LogHelper.getStackDescription(stack);
|
|
||||||
else
|
|
||||||
return "Unknown output";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeRecipe(IIngredient output) {
|
|
||||||
List<IArcaneRecipe> recipes = new LinkedList<IArcaneRecipe>();
|
|
||||||
|
|
||||||
for(Object o : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if(o != null && o instanceof IArcaneRecipe) {
|
|
||||||
IArcaneRecipe recipe = (IArcaneRecipe)o;
|
|
||||||
|
|
||||||
if(recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) {
|
|
||||||
recipes.add(recipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!recipes.isEmpty()) {
|
|
||||||
MineTweakerAPI.apply(new Remove(recipes));
|
|
||||||
} else {
|
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command Ignored", Arcane.name, output.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Remove extends BaseListRemoval<IArcaneRecipe> {
|
|
||||||
public Remove(List<IArcaneRecipe> recipes) {
|
|
||||||
super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(IArcaneRecipe recipe) {
|
|
||||||
ItemStack stack = recipe.getRecipeOutput();
|
|
||||||
|
|
||||||
if(stack instanceof ItemStack)
|
|
||||||
return LogHelper.getStackDescription(stack);
|
|
||||||
else
|
|
||||||
return "Unknown output";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,236 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.handlers;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.toStack;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import modtweaker2.utils.BaseUndoable;
|
|
||||||
import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
import thaumcraft.api.ThaumcraftApiHelper;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
|
||||||
|
|
||||||
@ZenClass("mods.thaumcraft.Aspects")
|
|
||||||
public class Aspects {
|
|
||||||
/** Add/Remove/Set Aspects for items **/
|
|
||||||
@ZenMethod
|
|
||||||
public static void add(IItemStack stack, String aspects) {
|
|
||||||
MineTweakerAPI.apply(new Add(toStack(stack), aspects, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void set(IItemStack stack, String aspects) {
|
|
||||||
MineTweakerAPI.apply(new Add(toStack(stack), aspects, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds or sets Aspects
|
|
||||||
private static class Add extends BaseUndoable {
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final String aspects;
|
|
||||||
private final boolean replace;
|
|
||||||
private AspectList oldList;
|
|
||||||
private AspectList newList;
|
|
||||||
|
|
||||||
public Add(ItemStack stack, String aspects, boolean replace) {
|
|
||||||
super("Aspects");
|
|
||||||
this.stack = stack;
|
|
||||||
this.aspects = aspects;
|
|
||||||
this.replace = replace;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
oldList = new AspectList(stack);
|
|
||||||
if (!replace)
|
|
||||||
newList = ThaumcraftHelper.parseAspects(oldList, aspects);
|
|
||||||
else
|
|
||||||
newList = ThaumcraftHelper.parseAspects(aspects);
|
|
||||||
|
|
||||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if (oldList == null) {
|
|
||||||
ThaumcraftApi.objectTags.remove(Arrays.asList(stack.getItem(), stack.getItemDamage()));
|
|
||||||
} else
|
|
||||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRecipeInfo() {
|
|
||||||
return stack.getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void remove(IItemStack stack, String aspects) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new Remove(toStack(stack), aspects));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Remove extends BaseUndoable {
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final String aspects;
|
|
||||||
private AspectList oldList;
|
|
||||||
private AspectList newList;
|
|
||||||
|
|
||||||
public Remove(ItemStack stack, String aspects) {
|
|
||||||
super("Aspects");
|
|
||||||
this.stack = stack;
|
|
||||||
this.aspects = aspects;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
oldList = new AspectList(stack);
|
|
||||||
if (oldList != null) {
|
|
||||||
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
|
|
||||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
|
|
||||||
}
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return oldList != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRecipeInfo() {
|
|
||||||
return stack.getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Add/Remove/Set Aspects for entities **/
|
|
||||||
@ZenMethod
|
|
||||||
public static void addEntity(String entityName, String aspects) {
|
|
||||||
if (!EntityList.stringToClassMapping.containsKey(entityName)) {
|
|
||||||
MineTweakerAPI.getLogger().logError("No such entity " + entityName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddEntity(entityName, aspects, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setEntity(String entityName, String aspects) {
|
|
||||||
if (!EntityList.stringToClassMapping.containsKey(entityName)) {
|
|
||||||
MineTweakerAPI.getLogger().logError("No such entity " + entityName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddEntity(entityName, aspects, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds or sets Aspects
|
|
||||||
private static class AddEntity extends BaseUndoable {
|
|
||||||
private final String entityName;
|
|
||||||
private final String aspects;
|
|
||||||
private final boolean replace;
|
|
||||||
private AspectList oldList;
|
|
||||||
private AspectList newList;
|
|
||||||
|
|
||||||
public AddEntity(String entityName, String aspects, boolean replace) {
|
|
||||||
super("Aspects");
|
|
||||||
this.entityName = entityName;
|
|
||||||
this.aspects = aspects;
|
|
||||||
this.replace = replace;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
oldList = ThaumcraftHelper.getEntityAspects(entityName);
|
|
||||||
if (!replace)
|
|
||||||
newList = ThaumcraftHelper.parseAspects(oldList, aspects);
|
|
||||||
else
|
|
||||||
newList = ThaumcraftHelper.parseAspects(aspects);
|
|
||||||
ThaumcraftHelper.removeEntityAspects(entityName);
|
|
||||||
ThaumcraftApi.registerEntityTag(entityName, newList);
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ThaumcraftHelper.removeEntityAspects(entityName);
|
|
||||||
if (oldList != null)
|
|
||||||
ThaumcraftApi.registerEntityTag(entityName, oldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRecipeInfo() {
|
|
||||||
return entityName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeEntity(String entityName, String aspects) {
|
|
||||||
if (!EntityList.stringToClassMapping.containsKey(entityName)) {
|
|
||||||
MineTweakerAPI.getLogger().logError("No such entity " + entityName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new RemoveEntity(entityName, aspects));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RemoveEntity extends BaseUndoable {
|
|
||||||
private final String entityName;
|
|
||||||
private final String aspects;
|
|
||||||
private AspectList oldList;
|
|
||||||
private AspectList newList;
|
|
||||||
|
|
||||||
public RemoveEntity(String entityName, String aspects) {
|
|
||||||
super("Aspects");
|
|
||||||
this.entityName = entityName;
|
|
||||||
this.aspects = aspects;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
oldList = ThaumcraftHelper.getEntityAspects(entityName);
|
|
||||||
if (oldList != null) {
|
|
||||||
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
|
|
||||||
ThaumcraftHelper.removeEntityAspects(entityName);
|
|
||||||
ThaumcraftApi.registerEntityTag(entityName, newList);
|
|
||||||
}
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return oldList != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ThaumcraftHelper.removeEntityAspects(entityName);
|
|
||||||
ThaumcraftApi.registerEntityTag(entityName, oldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRecipeInfo() {
|
|
||||||
return entityName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.handlers;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
|
||||||
import static modtweaker2.helpers.InputHelper.toObject;
|
|
||||||
import static modtweaker2.helpers.InputHelper.toStack;
|
|
||||||
import static modtweaker2.helpers.StackHelper.matches;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import modtweaker2.helpers.LogHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import modtweaker2.utils.BaseListAddition;
|
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
import thaumcraft.api.crafting.CrucibleRecipe;
|
|
||||||
|
|
||||||
@ZenClass("mods.thaumcraft.Crucible")
|
|
||||||
public class Crucible {
|
|
||||||
|
|
||||||
public static final String name = "Thaumcraft Crucible";
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addRecipe(String key[], IItemStack result, IIngredient catalyst, String aspects) {
|
|
||||||
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Add extends BaseListAddition<CrucibleRecipe> {
|
|
||||||
public Add(CrucibleRecipe recipe) {
|
|
||||||
super(Crucible.name, ThaumcraftApi.getCraftingRecipes());
|
|
||||||
recipes.add(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(CrucibleRecipe recipe) {
|
|
||||||
return LogHelper.getStackDescription(recipe.getRecipeOutput());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeRecipe(IIngredient output) {
|
|
||||||
List<CrucibleRecipe> recipes = new LinkedList<CrucibleRecipe>();
|
|
||||||
|
|
||||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (o instanceof CrucibleRecipe) {
|
|
||||||
CrucibleRecipe r = (CrucibleRecipe) o;
|
|
||||||
if (r.getRecipeOutput() != null && matches(output, toIItemStack(r.getRecipeOutput()))) {
|
|
||||||
recipes.add(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!recipes.isEmpty()) {
|
|
||||||
MineTweakerAPI.apply(new Remove(recipes));
|
|
||||||
} else {
|
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crucible.name, output.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Remove extends BaseListRemoval<CrucibleRecipe> {
|
|
||||||
public Remove(List<CrucibleRecipe> recipes) {
|
|
||||||
super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(CrucibleRecipe recipe) {
|
|
||||||
return LogHelper.getStackDescription(recipe.getRecipeOutput());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,151 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.handlers;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
|
||||||
import static modtweaker2.helpers.InputHelper.toStack;
|
|
||||||
import static modtweaker2.helpers.InputHelper.toStacks;
|
|
||||||
import static modtweaker2.helpers.StackHelper.matches;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import modtweaker2.helpers.LogHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe;
|
|
||||||
import modtweaker2.utils.BaseListAddition;
|
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
|
||||||
import net.minecraft.enchantment.Enchantment;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
import thaumcraft.api.crafting.InfusionEnchantmentRecipe;
|
|
||||||
import thaumcraft.api.crafting.InfusionRecipe;
|
|
||||||
|
|
||||||
@ZenClass("mods.thaumcraft.Infusion")
|
|
||||||
public class Infusion {
|
|
||||||
|
|
||||||
public static final String name = "Thaumcraft Infusion";
|
|
||||||
public static final String enchName = name + " Enchantment";
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new Add(new InfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe))));
|
|
||||||
}
|
|
||||||
|
|
||||||
// A version that allows you to specify whether the detection should be
|
|
||||||
// fuzzy or not
|
|
||||||
@ZenMethod
|
|
||||||
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) {
|
|
||||||
MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) {
|
|
||||||
MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.getEnchantmentById(enchantID), instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Add extends BaseListAddition<InfusionRecipe> {
|
|
||||||
public Add(InfusionRecipe recipe) {
|
|
||||||
super(Infusion.name, ThaumcraftApi.getCraftingRecipes());
|
|
||||||
recipes.add(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(InfusionRecipe recipe) {
|
|
||||||
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
|
|
||||||
if (out instanceof ItemStack) {
|
|
||||||
return ((ItemStack) out).getDisplayName();
|
|
||||||
} else
|
|
||||||
return "Unknown item";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class AddEnchant extends BaseListAddition<InfusionEnchantmentRecipe> {
|
|
||||||
public AddEnchant(InfusionEnchantmentRecipe inp) {
|
|
||||||
super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes());
|
|
||||||
recipes.add(inp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) {
|
|
||||||
return recipe.getEnchantment().getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeRecipe(IIngredient output) {
|
|
||||||
List<InfusionRecipe> recipes = new LinkedList<InfusionRecipe>();
|
|
||||||
|
|
||||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (o instanceof InfusionRecipe) {
|
|
||||||
InfusionRecipe r = (InfusionRecipe) o;
|
|
||||||
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && matches(output, toIItemStack((ItemStack)r.getRecipeOutput()))) {
|
|
||||||
recipes.add(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!recipes.isEmpty()) {
|
|
||||||
MineTweakerAPI.apply(new Remove(recipes));
|
|
||||||
} else {
|
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.name, output.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeEnchant(int id) {
|
|
||||||
List<InfusionEnchantmentRecipe> recipes = new LinkedList<InfusionEnchantmentRecipe>();
|
|
||||||
Enchantment ench = Enchantment.getEnchantmentById(id);
|
|
||||||
|
|
||||||
for (Object recipe : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (recipe instanceof InfusionEnchantmentRecipe) {
|
|
||||||
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
|
|
||||||
if (enchRecipe.getEnchantment() == ench) {
|
|
||||||
recipes.add(enchRecipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!recipes.isEmpty()) {
|
|
||||||
MineTweakerAPI.apply(new RemoveEnchant(recipes));
|
|
||||||
} else {
|
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.enchName + " Enchantment", ench.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Remove extends BaseListRemoval<InfusionRecipe> {
|
|
||||||
public Remove(List<InfusionRecipe> recipes) {
|
|
||||||
super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(InfusionRecipe recipe) {
|
|
||||||
|
|
||||||
Object o = recipe.getRecipeOutput();
|
|
||||||
|
|
||||||
if(o instanceof ItemStack) {
|
|
||||||
return LogHelper.getStackDescription((ItemStack)o);
|
|
||||||
} else {
|
|
||||||
return "Unknown Item";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RemoveEnchant extends BaseListRemoval<InfusionEnchantmentRecipe> {
|
|
||||||
public RemoveEnchant(List<InfusionEnchantmentRecipe> recipes) {
|
|
||||||
super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) {
|
|
||||||
return recipe.getEnchantment().getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.handlers;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
|
||||||
import static modtweaker2.helpers.StackHelper.matches;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import modtweaker2.helpers.InputHelper;
|
|
||||||
import modtweaker2.helpers.LogHelper;
|
|
||||||
import modtweaker2.utils.BaseListAddition;
|
|
||||||
import modtweaker2.utils.BaseListRemoval;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import thaumcraft.api.internal.WeightedRandomLoot;
|
|
||||||
|
|
||||||
@ZenClass("mods.thaumcraft.Loot")
|
|
||||||
public class Loot {
|
|
||||||
|
|
||||||
public static final String name = "Thaumcraft LootBag";
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addCommonLoot(IItemStack stack, int weight) {
|
|
||||||
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagCommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addUncommonLoot(IItemStack stack, int weight) {
|
|
||||||
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagUncommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addRareLoot(IItemStack stack, int weight) {
|
|
||||||
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Add extends BaseListAddition<WeightedRandomLoot> {
|
|
||||||
public Add(List<WeightedRandomLoot> list, WeightedRandomLoot recipe) {
|
|
||||||
super(Loot.name, list);
|
|
||||||
recipes.add(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(WeightedRandomLoot recipe) {
|
|
||||||
return LogHelper.getStackDescription(recipe.item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeCommonLoot(IIngredient stack) {
|
|
||||||
removeLoot(WeightedRandomLoot.lootBagCommon, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeUncommonLoot(IIngredient stack) {
|
|
||||||
removeLoot(WeightedRandomLoot.lootBagUncommon, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeRareLoot(IIngredient stack) {
|
|
||||||
removeLoot(WeightedRandomLoot.lootBagRare, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeLoot(List<WeightedRandomLoot> list, IIngredient ingredient) {
|
|
||||||
List<WeightedRandomLoot> recipes = new LinkedList<WeightedRandomLoot>();
|
|
||||||
|
|
||||||
for (WeightedRandomLoot loot : list) {
|
|
||||||
if (matches(ingredient, toIItemStack(loot.item))) {
|
|
||||||
recipes.add(loot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!recipes.isEmpty()) {
|
|
||||||
MineTweakerAPI.apply(new Remove(list, recipes));
|
|
||||||
} else {
|
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored.", Loot.name, ingredient.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Remove extends BaseListRemoval<WeightedRandomLoot> {
|
|
||||||
public Remove(List<WeightedRandomLoot> list, List<WeightedRandomLoot> recipes) {
|
|
||||||
super(Loot.name, list, recipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(WeightedRandomLoot recipe) {
|
|
||||||
return LogHelper.getStackDescription(recipe.item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,237 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.handlers;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.toStack;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import modtweaker2.helpers.InputHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.AddPage;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.AddPrereq;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.AddResearch;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.AddSibling;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.AddTab;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.ClearPages;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.ClearPrereqs;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.ClearSiblings;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.Difficulty;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.MoveResearch;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.OrphanResearch;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.RefreshResearch;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.RemoveResearch;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.RemoveTab;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.SetAspects;
|
|
||||||
import modtweaker2.mods.thaumcraft.research.SetResearch;
|
|
||||||
import net.minecraft.enchantment.Enchantment;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import thaumcraft.api.ThaumcraftApiHelper;
|
|
||||||
import thaumcraft.api.research.ResearchHelper;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
import thaumcraft.api.research.ResearchPage.PageType;
|
|
||||||
|
|
||||||
@ZenClass("mods.thaumcraft.Research")
|
|
||||||
public class Research {
|
|
||||||
private static final ResourceLocation defaultBackground = new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png");
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addTab(String key, String researchKey, String iconDomain, String iconPath) {
|
|
||||||
addTab(key,researchKey, iconDomain, iconPath, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addTab(String key,String researchKey, String iconDomain, String iconPath, String backDomain, String backPath) {
|
|
||||||
ResourceLocation icon = new ResourceLocation(iconDomain, iconPath);
|
|
||||||
ResourceLocation background;
|
|
||||||
if (backPath == null)
|
|
||||||
background = defaultBackground;
|
|
||||||
else
|
|
||||||
background = new ResourceLocation(backDomain, backPath);
|
|
||||||
addTab(key, researchKey, icon, background);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addTab(String key, String researchKey, ResourceLocation icon, ResourceLocation background) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddTab(key, researchKey, icon, background));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeTab(String tab) {
|
|
||||||
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new RemoveTab(tab));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeResearch(String research) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new RemoveResearch(research));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void orphanResearch(String research) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new OrphanResearch(research));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, String domain, String path) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, new ResourceLocation(domain, path)), null, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)),null, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item, IItemStack[] triggers, String[] entTriggers) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)), InputHelper.toStacks(triggers), entTriggers));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addPage(String key, String unlocalized) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addCraftingPage(String key, IItemStack item) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addCruciblePage(String key, IItemStack item) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addArcanePage(String key, IItemStack item) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addInfusionPage(String key, IItemStack item) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addEnchantmentPage(String key, int i) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.getEnchantmentById(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void clearPages(String key) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new ClearPages(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addPrereq(String key, String req, @Optional boolean hidden) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddPrereq(key, req, hidden));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void clearPrereqs(String key) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new ClearPrereqs(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addSibling(String key, String sibling) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new AddSibling(key, sibling));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void clearSiblings(String key) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new ClearSiblings(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setRound(String key, boolean flag) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setSpikey(String key, boolean flag) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setStub(String key, boolean flag) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setSecondary(String key, boolean flag) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setVirtual(String key, boolean flag) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setAutoUnlock(String key, boolean flag) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setConcealed(String key, boolean flag) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setAspects(String key, String aspects) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void setComplexity(String key, int complexity) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new Difficulty(key, complexity));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void refreshResearchRecipe(String key) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new RefreshResearch(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void moveResearch(String key, String destination, int x, int y) {
|
|
||||||
|
|
||||||
MineTweakerAPI.apply(new MoveResearch(key, destination, x, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static boolean hasResearched(IPlayer player, String key) {
|
|
||||||
return ResearchHelper.isResearchComplete(player.getName(), key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum SetType {
|
|
||||||
AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,231 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.handlers;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.toStack;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
|
|
||||||
@ZenClass("mods.thaumcraft.Warp")
|
|
||||||
public class Warp {
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addToResearch(String key, int warp) {
|
|
||||||
MineTweakerAPI.apply(new Add(key, warp));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void addToItem(IItemStack stack, int warp) {
|
|
||||||
MineTweakerAPI.apply(new Add(toStack(stack), warp));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Add implements IUndoableAction {
|
|
||||||
Object target;
|
|
||||||
int warp;
|
|
||||||
|
|
||||||
public Add(Object targ, int amount) {
|
|
||||||
target = targ;
|
|
||||||
warp = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void apply() {
|
|
||||||
if (target instanceof String)
|
|
||||||
ThaumcraftApi.addWarpToResearch((String) target, warp);
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
ThaumcraftApi.addWarpToItem((ItemStack) target, warp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canUndo() {
|
|
||||||
return ThaumcraftApi.getWarp(target) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describe() {
|
|
||||||
String desc = "Adding " + warp + " warp to ";
|
|
||||||
if (target instanceof String)
|
|
||||||
desc += (String) target;
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
desc += ((ItemStack) target).getDisplayName();
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undo() {
|
|
||||||
if (target instanceof String)
|
|
||||||
ThaumcraftHelper.warpList.remove(target);
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describeUndo() {
|
|
||||||
String desc = "Removing warp from ";
|
|
||||||
if (target instanceof String)
|
|
||||||
desc += (String) target;
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
desc += ((ItemStack) target).getDisplayName();
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeFromResearch(String key) {
|
|
||||||
MineTweakerAPI.apply(new Remove(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeFromItem(IItemStack stack) {
|
|
||||||
MineTweakerAPI.apply(new Remove(toStack(stack)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeAll() {
|
|
||||||
MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeAllResearch() {
|
|
||||||
MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static void removeAllItems() {
|
|
||||||
MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Remove implements IUndoableAction {
|
|
||||||
Object target;
|
|
||||||
int warp;
|
|
||||||
|
|
||||||
public Remove(Object targ) {
|
|
||||||
target = targ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void apply() {
|
|
||||||
if (target instanceof String)
|
|
||||||
warp = ThaumcraftHelper.warpList.remove(target);
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
warp = ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canUndo() {
|
|
||||||
return warp > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describe() {
|
|
||||||
String desc = "Removing warp from ";
|
|
||||||
if (target instanceof String)
|
|
||||||
desc += (String) target;
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
desc += ((ItemStack) target).getDisplayName();
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undo() {
|
|
||||||
if (target instanceof String)
|
|
||||||
ThaumcraftApi.addWarpToResearch((String) target, warp);
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
ThaumcraftApi.addWarpToItem((ItemStack) target, warp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describeUndo() {
|
|
||||||
String desc = "Restoring " + warp + " warp to ";
|
|
||||||
if (target instanceof String)
|
|
||||||
desc += (String) target;
|
|
||||||
else if (target instanceof ItemStack)
|
|
||||||
desc += ((ItemStack) target).getDisplayName();
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum RemoveType {
|
|
||||||
RESEARCH, ITEMS, BOTH
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MassRemove implements IUndoableAction {
|
|
||||||
HashMap<Object, Integer> oldMap = new HashMap<Object, Integer>();
|
|
||||||
RemoveType type;
|
|
||||||
|
|
||||||
public MassRemove(RemoveType typ) {
|
|
||||||
type = typ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void apply() {
|
|
||||||
if (type == RemoveType.BOTH) {
|
|
||||||
for (Object key : ThaumcraftHelper.warpList.keySet()) {
|
|
||||||
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
|
|
||||||
}
|
|
||||||
ThaumcraftHelper.warpList.clear();
|
|
||||||
} else if (type == RemoveType.ITEMS) {
|
|
||||||
for (Object key : ThaumcraftHelper.warpList.keySet()) {
|
|
||||||
if (key instanceof List) {
|
|
||||||
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Object key : oldMap.keySet()) {
|
|
||||||
ThaumcraftHelper.warpList.remove(key);
|
|
||||||
}
|
|
||||||
} else if (type == RemoveType.RESEARCH) {
|
|
||||||
for (Object key : ThaumcraftHelper.warpList.keySet()) {
|
|
||||||
if (key instanceof String) {
|
|
||||||
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Object key : oldMap.keySet()) {
|
|
||||||
ThaumcraftHelper.warpList.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canUndo() {
|
|
||||||
return oldMap.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describe() {
|
|
||||||
if (type == RemoveType.RESEARCH)
|
|
||||||
return "Clearing All Research Warp";
|
|
||||||
else if (type == RemoveType.ITEMS)
|
|
||||||
return "Clearing All Item Warp";
|
|
||||||
else
|
|
||||||
return "Clearing All Warp";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undo() {
|
|
||||||
for (Object key : oldMap.keySet()) {
|
|
||||||
ThaumcraftHelper.warpList.put(key, oldMap.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describeUndo() {
|
|
||||||
if (type == RemoveType.RESEARCH)
|
|
||||||
return "Restoring All Research Warp";
|
|
||||||
else if (type == RemoveType.ITEMS)
|
|
||||||
return "Restoring All Item Warp";
|
|
||||||
else
|
|
||||||
return "Restoring All Warp";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.recipe;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import thaumcraft.api.ThaumcraftApiHelper;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
|
||||||
import thaumcraft.api.crafting.InfusionRecipe;
|
|
||||||
import thaumcraft.api.research.ResearchHelper;
|
|
||||||
|
|
||||||
public class MTInfusionRecipe extends InfusionRecipe {
|
|
||||||
private final boolean fuzzyCentre;
|
|
||||||
private final boolean[] fuzzyRecipe;
|
|
||||||
|
|
||||||
public MTInfusionRecipe(String research, Object output, int inst, AspectList aspects2, ItemStack input, ItemStack[] recipe, boolean fuzzyCentre, boolean[] fuzzyRecipe) {
|
|
||||||
super(research, output, inst, aspects2, input, recipe);
|
|
||||||
this.fuzzyCentre = fuzzyCentre;
|
|
||||||
this.fuzzyRecipe = fuzzyRecipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) {
|
|
||||||
// if (getRecipeInput() == null) return false;
|
|
||||||
//
|
|
||||||
// if (research.length > 0 && !ResearchHelper.isResearchComplete(player.getName(), research)) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ItemStack i2 = central.copy();
|
|
||||||
// ItemStack recInput = (ItemStack)getRecipeInput();
|
|
||||||
// if (recInput.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
|
||||||
// i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// if (!areItemStacksEqual(i2, recInput, fuzzyCentre)) return false;
|
|
||||||
//
|
|
||||||
// ArrayList<ItemStack> ii = new ArrayList<ItemStack>();
|
|
||||||
// for (ItemStack is : input) {
|
|
||||||
// ii.add(is.copy());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (int j = 0; j < getComponents().length; j++) {
|
|
||||||
// ItemStack comp = (ItemStack)getComponents()[j];
|
|
||||||
// boolean b = false;
|
|
||||||
// for (int a = 0; a < ii.size(); a++) {
|
|
||||||
// i2 = ii.get(a).copy();
|
|
||||||
// if (comp.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
|
||||||
// i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (areItemStacksEqual(i2, comp, fuzzyRecipe[j])) {
|
|
||||||
// ii.remove(a);
|
|
||||||
// b = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!b) return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return ii.size() == 0 ? true : false;
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import net.minecraft.enchantment.Enchantment;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
import thaumcraft.api.crafting.CrucibleRecipe;
|
|
||||||
import thaumcraft.api.crafting.IArcaneRecipe;
|
|
||||||
import thaumcraft.api.crafting.InfusionEnchantmentRecipe;
|
|
||||||
import thaumcraft.api.crafting.InfusionRecipe;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchPage;
|
|
||||||
import thaumcraft.api.research.ResearchPage.PageType;
|
|
||||||
|
|
||||||
public class AddPage implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
ResearchPage page;
|
|
||||||
ResearchPage[] oldPages;
|
|
||||||
PageType type;
|
|
||||||
ItemStack target;
|
|
||||||
Enchantment enchant;
|
|
||||||
|
|
||||||
public AddPage(String res, PageType a, Object b) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
type = a;
|
|
||||||
if (type == PageType.TEXT) page = new ResearchPage((String) b);
|
|
||||||
else if (type == PageType.INFUSION_ENCHANTMENT) enchant = (Enchantment) b;
|
|
||||||
if (b instanceof ItemStack) target = (ItemStack) b;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if (type == PageType.NORMAL_CRAFTING) {
|
|
||||||
for (Object craft : CraftingManager.getInstance().getRecipeList()) {
|
|
||||||
if (craft instanceof IRecipe) {
|
|
||||||
IRecipe theCraft = (IRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), target)) {
|
|
||||||
page = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (type == PageType.ARCANE_CRAFTING) {
|
|
||||||
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (craft instanceof IArcaneRecipe) {
|
|
||||||
IArcaneRecipe theCraft = (IArcaneRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), target)) {
|
|
||||||
page = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (type == PageType.CRUCIBLE_CRAFTING) {
|
|
||||||
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (craft instanceof CrucibleRecipe) {
|
|
||||||
CrucibleRecipe theCraft = (CrucibleRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), target)) {
|
|
||||||
page = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (type == PageType.INFUSION_CRAFTING) {
|
|
||||||
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (craft instanceof InfusionRecipe) {
|
|
||||||
InfusionRecipe theCraft = (InfusionRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && theCraft.getRecipeOutput() instanceof ItemStack && areEqual(((ItemStack) (theCraft.getRecipeOutput())), target)) {
|
|
||||||
page = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (type == PageType.INFUSION_ENCHANTMENT) {
|
|
||||||
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (craft instanceof InfusionEnchantmentRecipe) {
|
|
||||||
InfusionEnchantmentRecipe theCraft = (InfusionEnchantmentRecipe) craft;
|
|
||||||
if (theCraft.getEnchantment() != null && theCraft.getEnchantment() == enchant) {
|
|
||||||
page = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (page == null) return;
|
|
||||||
oldPages = ResearchCategories.researchCategories.get(tab).research.get(key).getPages();
|
|
||||||
if (oldPages == null) oldPages = new ResearchPage[0];
|
|
||||||
ResearchPage[] newPages = new ResearchPage[oldPages.length + 1];
|
|
||||||
for (int x = 0; x < oldPages.length; x++) {
|
|
||||||
newPages[x] = oldPages[x];
|
|
||||||
}
|
|
||||||
newPages[oldPages.length] = page;
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(newPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding Research Page to " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return oldPages != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(oldPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing Page from " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class AddPrereq implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
String prereq;
|
|
||||||
String[] oldPrereqs;
|
|
||||||
boolean hidden;
|
|
||||||
|
|
||||||
public AddPrereq(String res, String req, boolean secret) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
prereq = req;
|
|
||||||
hidden = secret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if (!hidden) {
|
|
||||||
oldPrereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parents;
|
|
||||||
if (oldPrereqs == null) oldPrereqs = new String[0];
|
|
||||||
String[] newPrereqs = new String[oldPrereqs.length + 1];
|
|
||||||
for (int x = 0; x < oldPrereqs.length; x++) {
|
|
||||||
newPrereqs[x] = oldPrereqs[x];
|
|
||||||
}
|
|
||||||
newPrereqs[oldPrereqs.length] = prereq;
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setParents(newPrereqs);
|
|
||||||
} else {
|
|
||||||
oldPrereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parentsHidden;
|
|
||||||
if (oldPrereqs == null) oldPrereqs = new String[0];
|
|
||||||
String[] newPrereqs = new String[oldPrereqs.length + 1];
|
|
||||||
for (int x = 0; x < oldPrereqs.length; x++) {
|
|
||||||
newPrereqs[x] = oldPrereqs[x];
|
|
||||||
}
|
|
||||||
newPrereqs[oldPrereqs.length] = prereq;
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(newPrereqs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding Prerequisites to " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return oldPrereqs != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if (!hidden) ResearchCategories.researchCategories.get(tab).research.get(key).setParents(oldPrereqs);
|
|
||||||
else ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(oldPrereqs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Prerequisites for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
|
|
||||||
public class AddResearch implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
ResearchItem research;
|
|
||||||
ItemStack[] itemTriggers;
|
|
||||||
String[] entityTriggers;
|
|
||||||
|
|
||||||
public AddResearch(ResearchItem res, ItemStack[] triggers, String[] entTriggers) {
|
|
||||||
research = res;
|
|
||||||
tab = research.category;
|
|
||||||
key = research.key;
|
|
||||||
itemTriggers = triggers;
|
|
||||||
entityTriggers = entTriggers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
// if (itemTriggers != null) {
|
|
||||||
// research = research.settrsetItemTriggers(itemTriggers);
|
|
||||||
// }
|
|
||||||
// if (entityTriggers != null) {
|
|
||||||
// research = research.setEntityTriggers(entityTriggers);
|
|
||||||
// }
|
|
||||||
research.registerResearchItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Registering Research: " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return tab != null && key != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing Research: " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class AddSibling implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
String sibling;
|
|
||||||
String[] oldSiblings;
|
|
||||||
|
|
||||||
public AddSibling(String res, String sib) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
sibling = sib;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
oldSiblings = ResearchCategories.researchCategories.get(tab).research.get(key).siblings;
|
|
||||||
if (oldSiblings == null) oldSiblings = new String[0];
|
|
||||||
String[] newSiblings = new String[oldSiblings.length + 1];
|
|
||||||
for (int x = 0; x < oldSiblings.length; x++) {
|
|
||||||
newSiblings[x] = oldSiblings[x];
|
|
||||||
}
|
|
||||||
newSiblings[oldSiblings.length] = sibling;
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(sibling);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding Sibling to " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return oldSiblings != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(oldSiblings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Siblings for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class AddTab implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
ResourceLocation icon;
|
|
||||||
ResourceLocation background;
|
|
||||||
|
|
||||||
public AddTab(String key, String research, ResourceLocation pic, ResourceLocation back) {
|
|
||||||
this.key = key;
|
|
||||||
icon = pic;
|
|
||||||
background = back;
|
|
||||||
tab = research;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
ResearchCategories.registerCategory(key, tab, icon, background);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Registering Research Tab: " + tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.remove(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing Research Tab: " + tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchPage;
|
|
||||||
|
|
||||||
public class ClearPages implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
ResearchPage[] oldPages;
|
|
||||||
|
|
||||||
public ClearPages(String res) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
oldPages = ResearchCategories.researchCategories.get(tab).research.get(key).getPages();
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(new ResearchPage[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Clearing Research Pages from " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return oldPages != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(oldPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Pages to " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class ClearPrereqs implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
String[] prereqs;
|
|
||||||
String[] secretPrereqs;
|
|
||||||
|
|
||||||
public ClearPrereqs(String res) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
prereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parents;
|
|
||||||
secretPrereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parentsHidden;
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setParents(new String[0]);
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(new String[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Clearing Prerequisites for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return prereqs != null || secretPrereqs != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if (prereqs != null) ResearchCategories.researchCategories.get(tab).research.get(key).setParents(prereqs);
|
|
||||||
if (secretPrereqs != null) ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(secretPrereqs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Prerequisites for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class ClearSiblings implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
String[] siblings;
|
|
||||||
|
|
||||||
public ClearSiblings(String res) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
siblings = ResearchCategories.researchCategories.get(tab).research.get(key).siblings;
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(new String[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Clearing Siblings for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return siblings != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(siblings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Siblings for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
|
|
||||||
public class Difficulty implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
int difficulty;
|
|
||||||
int oldDif;
|
|
||||||
boolean applied = false;
|
|
||||||
|
|
||||||
public Difficulty(String res, int dif) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
difficulty = dif;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key);
|
|
||||||
oldDif = research.getComplexity();
|
|
||||||
try {
|
|
||||||
Field complexity = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("complexity");
|
|
||||||
complexity.setAccessible(true);
|
|
||||||
complexity.set(research, difficulty);
|
|
||||||
applied = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Changing Complexity for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return applied;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
try {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key);
|
|
||||||
Field complexity = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("complexity");
|
|
||||||
complexity.setAccessible(true);
|
|
||||||
complexity.set(research, oldDif);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Complexity for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
|
|
||||||
public class MoveResearch implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String newTab;
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
String oldTab;
|
|
||||||
int oldX;
|
|
||||||
int oldY;
|
|
||||||
boolean moved = false;
|
|
||||||
|
|
||||||
public MoveResearch(String research, String destination, int ex, int wy) {
|
|
||||||
key = research;
|
|
||||||
oldTab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
newTab = destination;
|
|
||||||
x = ex;
|
|
||||||
y = wy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if (oldTab != null) {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(oldTab).research.get(key);
|
|
||||||
oldX = research.displayColumn;
|
|
||||||
oldY = research.displayRow;
|
|
||||||
try {
|
|
||||||
Class res = Class.forName("thaumcraft.api.research.ResearchItem");
|
|
||||||
Field ex = res.getField("displayColumn");
|
|
||||||
ex.setAccessible(true);
|
|
||||||
ex.setInt(research, x);
|
|
||||||
Field wy = res.getField("displayRow");
|
|
||||||
wy.setAccessible(true);
|
|
||||||
wy.setInt(research, y);
|
|
||||||
Field cat = res.getField("category");
|
|
||||||
cat.setAccessible(true);
|
|
||||||
cat.set(research, newTab);
|
|
||||||
ResearchCategories.researchCategories.get(oldTab).research.remove(key);
|
|
||||||
research.registerResearchItem();
|
|
||||||
moved = true;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Moving Research " + key + " to " + newTab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return moved;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(oldTab).research.get(key);
|
|
||||||
try {
|
|
||||||
Class res = Class.forName("thaumcraft.api.research.ResearchItem");
|
|
||||||
Field ex = res.getField("displayColumn");
|
|
||||||
ex.setAccessible(true);
|
|
||||||
ex.setInt(research, oldX);
|
|
||||||
Field wy = res.getField("displayRow");
|
|
||||||
wy.setAccessible(true);
|
|
||||||
wy.setInt(research, oldY);
|
|
||||||
Field cat = res.getField("category");
|
|
||||||
cat.setAccessible(true);
|
|
||||||
cat.set(research, oldTab);
|
|
||||||
ResearchCategories.researchCategories.get(newTab).research.remove(key);
|
|
||||||
research.registerResearchItem();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Moving Research " + key + " back to " + oldTab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class OrphanResearch implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
HashMap<String, String> children = new HashMap();
|
|
||||||
HashMap<String, String> secretChildren = new HashMap();
|
|
||||||
HashMap<String, String> siblings = new HashMap();
|
|
||||||
|
|
||||||
public OrphanResearch(String victim) {
|
|
||||||
key = victim;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
for (String tab : ResearchCategories.researchCategories.keySet()) {
|
|
||||||
for (String research : ResearchCategories.researchCategories.get(tab).research.keySet()) {
|
|
||||||
String[] prereqs = ResearchCategories.researchCategories.get(tab).research.get(research).parents;
|
|
||||||
if (prereqs != null) {
|
|
||||||
for (int x = 0; x < prereqs.length; x++) {
|
|
||||||
if (prereqs[x] != null && prereqs[x].equals(key)) {
|
|
||||||
children.put(research, tab);
|
|
||||||
ArrayList<String> newReqs = new ArrayList();
|
|
||||||
for (int y = 0; y < prereqs.length; y++) {
|
|
||||||
if (y != x) newReqs.add(prereqs[y]);
|
|
||||||
}
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(research).setParents(newReqs.toArray(new String[prereqs.length - 1]));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prereqs = ResearchCategories.researchCategories.get(tab).research.get(research).parentsHidden;
|
|
||||||
if (prereqs != null) {
|
|
||||||
for (int x = 0; x < prereqs.length; x++) {
|
|
||||||
if (prereqs[x] != null && prereqs[x].equals(key)) {
|
|
||||||
secretChildren.put(research, tab);
|
|
||||||
ArrayList<String> newReqs = new ArrayList();
|
|
||||||
for (int y = 0; y < prereqs.length; y++) {
|
|
||||||
if (y != x) newReqs.add(prereqs[y]);
|
|
||||||
}
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(research).setParentsHidden(newReqs.toArray(new String[prereqs.length - 1]));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prereqs = ResearchCategories.researchCategories.get(tab).research.get(research).siblings;
|
|
||||||
if (prereqs != null) {
|
|
||||||
for (int x = 0; x < prereqs.length; x++) {
|
|
||||||
if (prereqs[x] != null && prereqs[x].equals(key)) {
|
|
||||||
siblings.put(research, tab);
|
|
||||||
ArrayList<String> newReqs = new ArrayList();
|
|
||||||
for (int y = 0; y < prereqs.length; y++) {
|
|
||||||
if (y != x) newReqs.add(prereqs[y]);
|
|
||||||
}
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.get(research).setSiblings(newReqs.toArray(new String[prereqs.length - 1]));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Orphaning Research: " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return children.size() > 0 || secretChildren.size() > 0 || siblings.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if (children.size() > 0) {
|
|
||||||
for (String research : children.keySet()) {
|
|
||||||
String[] oldPrereqs = ResearchCategories.researchCategories.get(children.get(research)).research.get(research).parents;
|
|
||||||
String[] newReqs = new String[oldPrereqs.length + 1];
|
|
||||||
for (int x = 0; x < oldPrereqs.length; x++) {
|
|
||||||
newReqs[x] = oldPrereqs[x];
|
|
||||||
}
|
|
||||||
newReqs[oldPrereqs.length] = key;
|
|
||||||
ResearchCategories.researchCategories.get(children.get(research)).research.get(research).setParents(newReqs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (secretChildren.size() > 0) {
|
|
||||||
for (String research : secretChildren.keySet()) {
|
|
||||||
String[] oldPrereqs = ResearchCategories.researchCategories.get(secretChildren.get(research)).research.get(research).parentsHidden;
|
|
||||||
String[] newReqs = new String[oldPrereqs.length + 1];
|
|
||||||
for (int x = 0; x < oldPrereqs.length; x++) {
|
|
||||||
newReqs[x] = oldPrereqs[x];
|
|
||||||
}
|
|
||||||
newReqs[oldPrereqs.length] = key;
|
|
||||||
ResearchCategories.researchCategories.get(secretChildren.get(research)).research.get(research).setParentsHidden(newReqs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (siblings.size() > 0) {
|
|
||||||
for (String research : siblings.keySet()) {
|
|
||||||
String[] oldPrereqs = ResearchCategories.researchCategories.get(siblings.get(research)).research.get(research).siblings;
|
|
||||||
String[] newReqs = new String[oldPrereqs.length + 1];
|
|
||||||
for (int x = 0; x < oldPrereqs.length; x++) {
|
|
||||||
newReqs[x] = oldPrereqs[x];
|
|
||||||
}
|
|
||||||
newReqs[oldPrereqs.length] = key;
|
|
||||||
ResearchCategories.researchCategories.get(siblings.get(research)).research.get(research).setSiblings(newReqs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reattaching Research: " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,110 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
|
||||||
import thaumcraft.api.crafting.CrucibleRecipe;
|
|
||||||
import thaumcraft.api.crafting.IArcaneRecipe;
|
|
||||||
import thaumcraft.api.crafting.InfusionRecipe;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
import thaumcraft.api.research.ResearchPage;
|
|
||||||
|
|
||||||
public class RefreshResearch implements IUndoableAction {
|
|
||||||
String research;
|
|
||||||
String tab;
|
|
||||||
|
|
||||||
public RefreshResearch(String target) {
|
|
||||||
research = target;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(research);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if (tab != null) {
|
|
||||||
ResearchItem target = ResearchCategories.researchCategories.get(tab).research.get(research);
|
|
||||||
ResearchPage[] pages = target.getPages();
|
|
||||||
for (int x = 0; x < pages.length; x++) {
|
|
||||||
if (pages[x].recipe != null) {
|
|
||||||
if (pages[x].recipe instanceof IRecipe) {
|
|
||||||
IRecipe recipe = (IRecipe) pages[x].recipe;
|
|
||||||
for (Object craft : CraftingManager.getInstance().getRecipeList()) {
|
|
||||||
if (craft instanceof IRecipe) {
|
|
||||||
IRecipe theCraft = (IRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) {
|
|
||||||
pages[x] = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (pages[x].recipe instanceof IArcaneRecipe) {
|
|
||||||
IArcaneRecipe recipe = (IArcaneRecipe) pages[x].recipe;
|
|
||||||
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (craft instanceof IArcaneRecipe) {
|
|
||||||
IArcaneRecipe theCraft = (IArcaneRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) {
|
|
||||||
pages[x] = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (pages[x].recipe instanceof CrucibleRecipe) {
|
|
||||||
CrucibleRecipe recipe = (CrucibleRecipe) pages[x].recipe;
|
|
||||||
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (craft instanceof CrucibleRecipe) {
|
|
||||||
CrucibleRecipe theCraft = (CrucibleRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) {
|
|
||||||
pages[x] = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (pages[x].recipe instanceof InfusionRecipe) {
|
|
||||||
InfusionRecipe recipe = (InfusionRecipe) pages[x].recipe;
|
|
||||||
if (recipe.getRecipeOutput() instanceof ItemStack) {
|
|
||||||
for (Object craft : ThaumcraftApi.getCraftingRecipes()) {
|
|
||||||
if (craft instanceof InfusionRecipe) {
|
|
||||||
InfusionRecipe theCraft = (InfusionRecipe) craft;
|
|
||||||
if (theCraft.getRecipeOutput() != null && theCraft.getRecipeOutput() instanceof ItemStack && areEqual(((ItemStack) theCraft.getRecipeOutput()), (ItemStack) recipe.getRecipeOutput())) {
|
|
||||||
pages[x] = new ResearchPage(theCraft);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Refreshing Research: " + research;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return tab != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Refreshing Research Again?: " + research;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
|
|
||||||
public class RemoveResearch implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
ResearchItem removed;
|
|
||||||
|
|
||||||
public RemoveResearch(String victim) {
|
|
||||||
key = victim;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
if (tab != null) {
|
|
||||||
removed = ResearchCategories.researchCategories.get(tab).research.get(key);
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Removing Research: " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return tab != null && removed != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.get(tab).research.put(key, removed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Research: " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchCategoryList;
|
|
||||||
|
|
||||||
public class RemoveTab implements IUndoableAction {
|
|
||||||
String tab;
|
|
||||||
ResearchCategoryList list;
|
|
||||||
|
|
||||||
public RemoveTab(String victim) {
|
|
||||||
tab = victim;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
list = ResearchCategories.getResearchList(tab);
|
|
||||||
ResearchCategories.researchCategories.remove(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Removing Research Tab: " + tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return list != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchCategories.researchCategories.put(tab, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Research Tab: " + tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
|
|
||||||
public class SetAspects implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
AspectList oldList;
|
|
||||||
AspectList list;
|
|
||||||
boolean applied = false;
|
|
||||||
|
|
||||||
public SetAspects(String res, AspectList asp) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
list = asp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key);
|
|
||||||
oldList = research.tags;
|
|
||||||
try {
|
|
||||||
Field tags = Class.forName("thaumcraft.api.research.ResearchItem").getField("tags");
|
|
||||||
tags.setAccessible(true);
|
|
||||||
tags.set(research, list);
|
|
||||||
applied = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Changing Aspects for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return applied;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
try {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key);
|
|
||||||
Field tags = Class.forName("thaumcraft.api.research.ResearchItem").getField("tags");
|
|
||||||
tags.setAccessible(true);
|
|
||||||
tags.set(research, oldList);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring Aspects for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,111 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
|
||||||
import modtweaker2.mods.thaumcraft.handlers.Research.SetType;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
import thaumcraft.api.research.ResearchItem;
|
|
||||||
|
|
||||||
public class SetResearch implements IUndoableAction {
|
|
||||||
String key;
|
|
||||||
String tab;
|
|
||||||
SetType type;
|
|
||||||
boolean flag;
|
|
||||||
boolean applied = false;
|
|
||||||
|
|
||||||
public SetResearch(String res, boolean f, SetType typ) {
|
|
||||||
key = res;
|
|
||||||
tab = ThaumcraftHelper.getResearchTab(key);
|
|
||||||
type = typ;
|
|
||||||
flag = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key);
|
|
||||||
if (flag) {
|
|
||||||
if (type == SetType.AUTO) research.setAutoUnlock();
|
|
||||||
else if (type == SetType.ROUND) research.setRound();
|
|
||||||
else if (type == SetType.SPIKE) research.setSpecial();
|
|
||||||
else if (type == SetType.SECONDARY) research.setSecondary();
|
|
||||||
else if (type == SetType.STUB) research.setStub();
|
|
||||||
// else if (type == SetType.VIRTUAL) research.setsetVirtual();
|
|
||||||
// else if (type == SetType.CONCEAL) research.setConcealed();
|
|
||||||
applied = true;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
Field target = null;
|
|
||||||
if (type == SetType.AUTO) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock");
|
|
||||||
else if (type == SetType.ROUND) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound");
|
|
||||||
else if (type == SetType.SPIKE) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial");
|
|
||||||
else if (type == SetType.SECONDARY) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary");
|
|
||||||
else if (type == SetType.STUB) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub");
|
|
||||||
else if (type == SetType.VIRTUAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual");
|
|
||||||
else if (type == SetType.CONCEAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed");
|
|
||||||
|
|
||||||
if (target != null) {
|
|
||||||
target.setAccessible(true);
|
|
||||||
target.setBoolean(research, false);
|
|
||||||
applied = true;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting tag for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return applied;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key);
|
|
||||||
if (!flag) {
|
|
||||||
if (type == SetType.AUTO) research.setAutoUnlock();
|
|
||||||
else if (type == SetType.ROUND) research.setRound();
|
|
||||||
else if (type == SetType.SPIKE) research.setSpecial();
|
|
||||||
else if (type == SetType.SECONDARY) research.setSecondary();
|
|
||||||
else if (type == SetType.STUB) research.setStub();
|
|
||||||
// else if (type == SetType.VIRTUAL) research.setVirtual();
|
|
||||||
// else if (type == SetType.CONCEAL) research.setConcealed();
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
Field target = null;
|
|
||||||
if (type == SetType.AUTO) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock");
|
|
||||||
else if (type == SetType.ROUND) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound");
|
|
||||||
else if (type == SetType.SPIKE) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial");
|
|
||||||
else if (type == SetType.SECONDARY) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary");
|
|
||||||
else if (type == SetType.STUB) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub");
|
|
||||||
else if (type == SetType.VIRTUAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual");
|
|
||||||
else if (type == SetType.CONCEAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed");
|
|
||||||
|
|
||||||
if (target != null) {
|
|
||||||
target.setAccessible(true);
|
|
||||||
target.setBoolean(research, false);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reversing tag for " + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package modtweaker2.mods.thaumcraft.research.commands;
|
|
||||||
|
|
||||||
import static modtweaker2.helpers.LogHelper.log;
|
|
||||||
import static modtweaker2.helpers.LogHelper.logPrinted;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.server.ICommandFunction;
|
|
||||||
import thaumcraft.api.research.ResearchCategories;
|
|
||||||
|
|
||||||
public class ResearchLogger implements ICommandFunction {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
if (arguments == null || arguments.length <= 0 || arguments[0] == null) {
|
|
||||||
System.out.println("Research Categories:");
|
|
||||||
MineTweakerAPI.logCommand("Research Categories:");
|
|
||||||
for (String tab : ResearchCategories.researchCategories.keySet()) {
|
|
||||||
System.out.println(tab);
|
|
||||||
MineTweakerAPI.logCommand(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
logPrinted(player);
|
|
||||||
} else if (arguments[0] != null && ResearchCategories.researchCategories.containsKey(arguments[0])) {
|
|
||||||
System.out.println("Research Keys for " + arguments[0] + ":");
|
|
||||||
MineTweakerAPI.logCommand("Research Keys for " + arguments[0] + ":");
|
|
||||||
for (String key : ResearchCategories.researchCategories.get(arguments[0]).research.keySet()) {
|
|
||||||
System.out.println(key);
|
|
||||||
MineTweakerAPI.logCommand(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
logPrinted(player);
|
|
||||||
} else if (arguments[0] != null && player != null) {
|
|
||||||
log(player, "Cannot find research category " + arguments[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue