Merge pull request #3 from stanhebben/master

sync
This commit is contained in:
Jared committed 2015-09-05 18:34:16 +02:00
commit be207cc3ca
329 files changed
+407 -32553

No files matched your search

+28 -34
View File
@@ -1,37 +1,31 @@
.nb-gradle
build
.gradle
run
/MineTweaker3-Web/nbproject/private/
/MineTweaker3-Web/doc
/MineTweaker3-MC164-Main/eclipse
/ZenScript-Test
*.class
/*
# Package Files #
*.war
*.ear
/build
*/eclipse
/bin
/out
!build.gradle
!/buildSrc/src/
!/MineTweaker3-API/src/
!/MineTweaker3-MC18-Main/src/
!/MineTweaker3-MC1710-Main/bin/
!/MineTweaker3-MC1710-Main/eclipse/
!/MineTweaker3-MC1710-Mod-Buildcraft/src/
!/MineTweaker3-MC1710-Mod-Buildcraft61/src/
!/MineTweaker3-MC1710-Mod-IC2/src/
!/MineTweaker3-MC1710-Mod-IC2/libs/
!/MineTweaker3-MC1710-Mod-MFR/src/
!/MineTweaker3-MC1710-Mod-MFR/libs/
!/MineTweaker3-MC1710-Mod-NEI/src/
!/MineTweaker3-MC1710-Mod-NEI/libs/
!/ZenScript/src/
!/MineTweaker3-Web/
*.mtl
*.classpath
*.project
/.settings
/.idea
/.gradle
*/.settings/
!/gradlew
!/gradlew.bat
!/gradle/
*.iml
*.ipr
*.iws
/.metadata/*
*.eml
usernamecache.json
MineTweaker3-MC1710-Main/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/Minecraft/.location
*.location
MineTweaker3-MC1710-Main/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/Minecraft/.location
MineTweaker3-MC164-Main/bin/assets/minetweaker/logo.png
MineTweaker3-MC164-Main/bin/mcmod.info
!/common.gradle
!/configuration.gradle
!/gradle.properties
MineTweaker3-Web/doc
nbproject/
Thumbs.db
-56
View File
@@ -1,56 +0,0 @@
import minetweaker.tasks.RegisterZenClassesTask;
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'forge'
minecraft {
version = forgeVersion164
}
version = "1.6.4-" + ext.mineTweakerVersion
//group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = project.projectDir.name
dependencies {
dependencies {
compile project(':ZenScript')
compile project(':MineTweaker3-API')
}
}
task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main')
outputDir = file('build/classes/main')
className = 'minetweaker.mc164.MineTweakerRegistry'
}
tasks.jar.dependsOn(makeRegistry)
processResources
{
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
Binary file not shown.
@@ -1,460 +0,0 @@
package minetweaker.api.minecraft;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import minetweaker.MineTweakerAPI;
import minetweaker.api.block.IBlock;
import minetweaker.api.block.IBlockDefinition;
import minetweaker.api.data.IData;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.oredict.IOreDictEntry;
import minetweaker.api.player.IPlayer;
import minetweaker.api.world.IBiome;
import minetweaker.api.world.IDimension;
import minetweaker.mc164.block.MCBlockDefinition;
import minetweaker.mc164.block.MCSpecificBlock;
import minetweaker.mc164.block.MCWorldBlock;
import minetweaker.mc164.data.NBTConverter;
import minetweaker.mc164.item.MCItemStack;
import minetweaker.mc164.oredict.MCOreDictEntry;
import minetweaker.mc164.player.MCPlayer;
import minetweaker.mc164.world.MCBiome;
import minetweaker.mc164.world.MCDimension;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
/**
* MineTweaker - MineCraft API bridge.
*
* @author Stan Hebben
*/
public class MineTweakerMC {
private static final Map<Block, MCBlockDefinition> blockDefinitions = new HashMap<Block, MCBlockDefinition>();
public static final IBiome[] biomes;
static {
biomes = new IBiome[BiomeGenBase.biomeList.length];
for (int i = 0; i < BiomeGenBase.biomeList.length; i++) {
if (BiomeGenBase.biomeList[i] != null)
biomes[i] = new MCBiome(BiomeGenBase.biomeList[i]);
}
}
private MineTweakerMC() {}
/**
* Returns the Minecraft item for this MineTweaker item.
*
* @param item minetweaker item stack
* @return minecraft item stack
*/
public static ItemStack getItemStack(IItemStack item) {
if (item == null) return null;
Object internal = item.getInternal();
if (internal == null || !(internal instanceof ItemStack)) {
MineTweakerAPI.logError("Not a valid item stack: " + item);
}
return (ItemStack) internal;
}
/**
* Returns the Minecraft ingredient for this ingredient. This method is only
* useful for ingredients that represent a single item stack.
*
* @param ingredient item ingredient
* @return minecraft item stack
*/
public static ItemStack getItemStack(IIngredient ingredient) {
if (ingredient == null) return null;
List<IItemStack> items = ingredient.getItems();
if (items.size() != 1) {
MineTweakerAPI.logError("Not an ingredient with a single item: " + ingredient);
}
return getItemStack(items.get(0));
}
/**
* Returns the MineTweaker item stack for this item.
*
* @param item minecraft item stack
* @return minetweaker item stack
*/
public static IItemStack getIItemStack(ItemStack item) {
if (item == null) return null;
return new MCItemStack(item);
}
/**
* Constructs an item stack with wildcard size.
*
* @param item minecraft item stack
* @return minetweaker stack
*/
public static IItemStack getIItemStackWildcardSize(ItemStack item) {
if (item == null) return null;
return new MCItemStack(item, true);
}
/**
* Constructs an item stack with wildcard size.
*
* @param item
* @param meta
* @return minetweaker stack
*/
public static IItemStack getIItemStackWildcardSize(Item item, int meta) {
if (item == null) return null;
return new MCItemStack(new ItemStack(item, 1, meta), true);
}
/**
* Constructs an item stack with wildcard damage.
*
* @param item stack item
* @param amount stack size
* @return minetweaker item stack
*/
public static IItemStack getIItemStackWildcard(Item item, int amount) {
if (item == null) return null;
return new MCItemStack(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE));
}
/**
* Constructs an item stack with given item, damage and amount.
*
* @param item stack item
* @param damage stack damage
* @param amount stack amount
* @return minetweaker item stack
*/
public static IItemStack getItemStack(Item item, int amount, int damage) {
if (item == null) return null;
return new MCItemStack(new ItemStack(item, amount, damage));
}
/**
* Converts an array of minetweaker item stacks into an array of minecraft
* item stacks.
*
* @param items minetweker item stacks
* @return minecraft item stacks
*/
public static ItemStack[] getItemStacks(IItemStack... items) {
if (items == null) return null;
ItemStack[] output = new ItemStack[items.length];
for (int i = 0; i < items.length; i++) {
Object internal = items[i].getInternal();
if (internal != null && internal instanceof ItemStack) {
output[i] = (ItemStack) internal;
}
}
return output;
}
/**
* Converts a list of minetweaker item stacks into an array of minecraft
* item stacks.
*
* @param items minetweaker items
* @return minecraft items
*/
public static ItemStack[] getItemStacks(List<IItemStack> items) {
if (items == null) return null;
ItemStack[] output = new ItemStack[items.size()];
for (int i = 0; i < items.size(); i++) {
Object internal = items.get(i).getInternal();
if (internal != null && internal instanceof ItemStack) {
output[i] = (ItemStack) internal;
} else {
MineTweakerAPI.logError("Invalid item stack: " + items.get(i));
}
}
return output;
}
/**
* Converts an array of minecraft item stacks into an array of minetweaker
* item stacks.
*
* @param items minecraft item stacks
* @return minetweaker item stacks
*/
public static IItemStack[] getIItemStacks(ItemStack... items) {
if (items == null) return null;
IItemStack[] result = new IItemStack[items.length];
for (int i = 0; i < items.length; i++) {
result[i] = new MCItemStack(items[i]);
}
return result;
}
/**
* Converts a list of minecraft item stacks into an array of minetweaker
* item stacks.
*
* @param items minecraft item stacks
* @return minetweaker item stacks
*/
public static IItemStack[] getIItemStacks(List<ItemStack> items) {
if (items == null) return null;
IItemStack[] result = new IItemStack[items.size()];
for (int i = 0; i < result.length; i++) {
result[i] = new MCItemStack(items.get(i));
}
return result;
}
/**
* Gets the ore dictionary entry with the given name. If the entry didn't
* exist yet, it will create it and return an empty entry.
*
* @param name ore entry name
* @return ore dictionary entry
*/
public static IOreDictEntry getOreDict(String name) {
return new MCOreDictEntry(name);
}
/**
* Converts a Minecraft player into a MineTweaker player.
*
* @param player minecraft player
* @return minetweaker player
*/
public static IPlayer getIPlayer(EntityPlayer player) {
if (player == null) return null;
return new MCPlayer(player);
}
/**
* Converts a MineTweaker player into a Minecraft player.
*
* @param player minetweaker player
* @return minecraft player
*/
public static EntityPlayer getPlayer(IPlayer player) {
if (player == null) return null;
if (!(player instanceof MCPlayer)) {
MineTweakerAPI.logError("Invalid player: " + player);
}
return ((MCPlayer) player).getInternal();
}
/**
* Converts a Minecraft NBT to an IData instance. The IData instance is
* immutable (not modifyiable).
*
* @param nbt nbt data
* @return IData value
*/
public static IData getIData(NBTBase nbt) {
if (nbt == null) return null;
return NBTConverter.from(nbt, true);
}
/**
* Converts a Minecraft NBT to a modifyable IData instance.
*
* @param nbt nbt data
* @return mutable IData value
*/
public static IData getIDataModifyable(NBTBase nbt) {
if (nbt == null) return null;
return NBTConverter.from(nbt, false);
}
/**
* Converts an IData instance to an NBT value.
*
* @param data IData value
* @return nbt data
*/
public static NBTBase getNBT(IData data) {
if (data == null) return null;
return NBTConverter.from(data);
}
/**
* Converts an IData instance to an NBT Tag compound.
*
* @param data IData value
* @return nbt compound data
*/
public static NBTTagCompound getNBTCompound(IData data) {
if (data == null) return null;
return (NBTTagCompound) NBTConverter.from(data);
}
/**
* Retrieves the block at the given position.
*
* @param blocks block access
* @param x block x position
* @param y block y position
* @param z block z position
* @return block instance
*/
public static IBlock getBlock(IBlockAccess blocks, int x, int y, int z) {
return new MCWorldBlock(blocks, x, y, z);
}
/**
* Retrieves the block definition for the given block.
*
* @param block block object
* @return block definition
*/
public static IBlockDefinition getBlockDefinition(Block block) {
if (!blockDefinitions.containsKey(block)) {
blockDefinitions.put(block, new MCBlockDefinition(block));
}
return blockDefinitions.get(block);
}
/**
* Retrieves the block from an item stack.
*
* @param itemStack
* @return
*/
public static Block getBlock(IItemStack itemStack) {
return ((MCBlockDefinition) itemStack.asBlock().getDefinition()).getInternalBlock();
}
/**
* Retrieves the dimension instance for a given world.
*
* @param world world
* @return dimension
*/
public static IDimension getDimension(World world) {
if (world == null) return null;
return new MCDimension(world);
}
/**
* Returns an instance of the given block.
*
* @param block MC block definition
* @return MT block instance
*/
public static IBlock getBlockAnyMeta(Block block) {
return new MCSpecificBlock(block, OreDictionary.WILDCARD_VALUE);
}
/**
* Returns an instance of the given block.
*
* @param block MC block definition
* @param meta block meta value
* @return MT block instance
*/
public static IBlock getBlock(Block block, int meta) {
return new MCSpecificBlock(block, meta);
}
/**
* Retrieves the internal fluid stack of the given stack.
*
* @param stack MT liquid stack
* @return MCF fluid stack
*/
public static FluidStack getLiquidStack(ILiquidStack stack) {
if (stack == null)
return null;
return (FluidStack) stack.getInternal();
}
public static int getBlockId(IBlockDefinition blockDefinition) {
if (blockDefinition instanceof MCBlockDefinition) {
return ((MCBlockDefinition) blockDefinition).getInternalId();
} else {
throw new IllegalArgumentException("block definition is not generated by MineTweaker");
}
}
public static ItemStack toItemStack(IBlock block) {
int mcBlockId = getBlockId(block.getDefinition());
ItemStack result = new ItemStack(mcBlockId, 1, block.getMeta());
IData data = block.getTileData();
if (data != null) {
result.setTagCompound(MineTweakerMC.getNBTCompound(data));
}
return result;
}
private static final HashMap<List, IOreDictEntry> oreDictArrays = new HashMap<List, IOreDictEntry>();
public static IOreDictEntry getOreDictEntryFromArray(List array) {
if (!oreDictArrays.containsKey(array)) {
for (String ore : OreDictionary.getOreNames()) {
if (OreDictionary.getOres(ore) == array) {
oreDictArrays.put(array, MineTweakerAPI.oreDict.get(ore));
}
}
}
return oreDictArrays.get(array);
}
/**
* Converts a Minecraft ingredient to a MineTweaker ingredient.
*
* @param ingredient minecraft ingredient
* @return minetweaker ingredient
*/
public static IIngredient getIIngredient(Object ingredient) {
if (ingredient == null) {
return null;
} else if (ingredient instanceof String) {
return MineTweakerAPI.oreDict.get((String) ingredient);
} else if (ingredient instanceof Item) {
return getIItemStack(new ItemStack((Item) ingredient, 1, 0));
} else if (ingredient instanceof ItemStack) {
return getIItemStack((ItemStack) ingredient);
} else if (ingredient instanceof List) {
IOreDictEntry entry = getOreDictEntryFromArray((List) ingredient);
if (entry == null) {
throw new IllegalArgumentException("No matching oredict entry: " + ingredient);
}
return entry;
} else {
throw new IllegalArgumentException("Not a valid ingredient: " + ingredient);
}
}
}
@@ -1,49 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.formatting.IFormattedText;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.tooltip.IngredientTooltips;
import minetweaker.mc164.formatting.IMCFormattedString;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import org.lwjgl.input.Keyboard;
/**
*
* @author Stan
*/
public class ForgeEventHandler {
@ForgeSubscribe
public void onPlayerInteract(PlayerInteractEvent ev) {
minetweaker.api.event.PlayerInteractEvent event = new minetweaker.api.event.PlayerInteractEvent(
MineTweakerMC.getIPlayer(ev.entityPlayer),
MineTweakerMC.getDimension(ev.entityPlayer.getEntityWorld()),
ev.x, ev.y, ev.z
);
MineTweakerImplementationAPI.events.publishPlayerInteract(event);
}
@ForgeSubscribe
public void onItemTooltip(ItemTooltipEvent ev) {
IItemStack itemStack = MineTweakerMC.getIItemStack(ev.itemStack);
for (IFormattedText tooltip : IngredientTooltips.getTooltips(itemStack)) {
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
}
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
for (IFormattedText tooltip : IngredientTooltips.getShiftTooltips(itemStack)) {
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
}
}
}
}
@@ -1,50 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164;
import cpw.mods.fml.common.network.PacketDispatcher;
import minetweaker.IPlatformFunctions;
import minetweaker.MineTweakerAPI;
import minetweaker.api.chat.IChatMessage;
import minetweaker.api.item.IItemDefinition;
import minetweaker.mc164.chat.MCChatMessage;
import minetweaker.mc164.item.MCItemDefinition;
import minetweaker.mc164.network.MCPacketHandler;
import net.minecraft.item.Item;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
/**
*
* @author Stan
*/
public class MCPlatformFunctions implements IPlatformFunctions {
public static final MCPlatformFunctions INSTANCE = new MCPlatformFunctions();
private MCPlatformFunctions() {}
@Override
public IChatMessage getMessage(String message) {
return new MCChatMessage(message);
}
@Override
public void distributeScripts(byte[] data) {
Packet packet = new Packet250CustomPayload(
MCPacketHandler.CHANNEL_SERVERSCRIPT,
MineTweakerAPI.tweaker.getScriptData());
PacketDispatcher.sendPacketToAllPlayers(packet);
}
@Override
public IItemDefinition getItemDefinition(int id) {
if (id < 0 || id >= Item.itemsList.length) return null;
Item item = Item.itemsList[id];
if (item == null) return null;
return new MCItemDefinition(item);
}
}
@@ -1,49 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164;
import cpw.mods.fml.common.ICraftingHandler;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.event.PlayerCraftedEvent;
import minetweaker.api.event.PlayerSmeltedEvent;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import minetweaker.mc164.recipes.MCCraftingInventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
/**
*
* @author Stan
*/
public class MTCraftingHandler implements ICraftingHandler {
@Override
public void onCrafting(EntityPlayer player, ItemStack crafting, IInventory craftMatrix) {
IPlayer iplayer = MineTweakerMC.getIPlayer(player);
if (MineTweakerMod.INSTANCE.recipes.hasTransformerRecipes()) {
MineTweakerMod.INSTANCE.recipes.applyTransformations(MCCraftingInventory.get(craftMatrix, player), iplayer);
}
if (MineTweakerImplementationAPI.events.hasPlayerCrafted()) {
MineTweakerImplementationAPI.events.publishPlayerCrafted(new PlayerCraftedEvent(
iplayer,
MineTweakerMC.getIItemStack(crafting),
MCCraftingInventory.get(craftMatrix, player)));
}
}
@Override
public void onSmelting(EntityPlayer ep, ItemStack is) {
if (MineTweakerImplementationAPI.events.hasPlayerSmelted()) {
MineTweakerImplementationAPI.events.publishPlayerSmelted(new PlayerSmeltedEvent(
MineTweakerMC.getIPlayer(ep),
MineTweakerMC.getIItemStack(is)));
}
}
}
@@ -1,222 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.GameRegistry;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.event.PlayerLoggedInEvent;
import minetweaker.api.event.PlayerLoggedOutEvent;
import minetweaker.api.logger.FileLogger;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.mc164.client.MCClient;
import minetweaker.mc164.formatting.MCFormatter;
import minetweaker.mc164.furnace.FuelTweaker;
import minetweaker.mc164.furnace.MCFurnaceManager;
import minetweaker.mc164.game.MCGame;
import minetweaker.mc164.mods.MCLoadedMods;
import minetweaker.mc164.network.MCConnectionHandler;
import minetweaker.mc164.network.MCPacketHandler;
import minetweaker.mc164.oredict.MCOreDict;
import minetweaker.mc164.recipes.MCRecipeManager;
import minetweaker.mc164.server.MCServer;
import minetweaker.mc164.util.MineTweakerHacks;
import minetweaker.mc164.util.MineTweakerPlatformUtils;
import minetweaker.mc164.vanilla.MCVanilla;
import minetweaker.runtime.IScriptProvider;
import minetweaker.runtime.providers.ScriptProviderCascade;
import minetweaker.runtime.providers.ScriptProviderCustom;
import minetweaker.runtime.providers.ScriptProviderDirectory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.common.MinecraftForge;
/**
* Main mod class. Performs some general logic, initialization of the API and
* FML event handling.
*
* @author Stan Hebben
*/
@Mod(modid = MineTweakerMod.MODID, version = "3.0.9B")
@NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = {MCPacketHandler.CHANNEL_SERVERSCRIPT, MCPacketHandler.CHANNEL_OPENBROWSER}, packetHandler = MCPacketHandler.class)
public class MineTweakerMod {
public static final String MODID = "MineTweaker3";
public static final String MCVERSION = "1.6.4";
private static final String[] REGISTRIES = {
"minetweaker.mods.ic2.ClassRegistry",
"minetweaker.mods.nei.ClassRegistry",
"minetweaker.mods.mfr.ClassRegistry",
"minetweaker.mods.gregtech.ClassRegistry",
"minetweaker.mods.buildcraft.ClassRegistry"
};
private static final String[] REGISTRY_DESCRIPTIONS = {
"IC2 mod support",
"NEI mod support",
"MFR mod support",
"GregTech mod support",
"Buildcraft mod support"
};
@Mod.Instance(MODID)
public static MineTweakerMod INSTANCE;
public final MCRecipeManager recipes;
private final IScriptProvider scriptsGlobal;
private final ScriptProviderCustom scriptsIMC;
private final Map<String, INetworkManager> networkByUser = new HashMap<String, INetworkManager>();
private final Map<INetworkManager, NetHandler> userByNetwork = new HashMap<INetworkManager, NetHandler>();
public MineTweakerMod() {
MineTweakerImplementationAPI.init(
new MCOreDict(),
recipes = new MCRecipeManager(),
new MCFurnaceManager(),
MCGame.INSTANCE,
new MCLoadedMods(),
new MCFormatter(),
new MCVanilla());
MineTweakerImplementationAPI.logger.addLogger(new FileLogger(new File("minetweaker.log")));
MineTweakerImplementationAPI.platform = MCPlatformFunctions.INSTANCE;
File globalDir = new File("scripts");
if (!globalDir.exists()) {
globalDir.mkdirs();
}
scriptsGlobal = new ScriptProviderDirectory(globalDir);
scriptsIMC = new ScriptProviderCustom("intermod");
MineTweakerImplementationAPI.setScriptProvider(scriptsGlobal);
}
public void onPlayerLogin(Player player, NetHandler netHandler, INetworkManager manager) {
networkByUser.put(netHandler.getPlayer().username, manager);
userByNetwork.put(manager, netHandler);
MineTweakerImplementationAPI.events.publishPlayerLoggedIn(
new PlayerLoggedInEvent(MineTweakerMC.getIPlayer(netHandler.getPlayer())));
}
public void onPlayerLogout(INetworkManager manager) {
// TODO: there appear to be some problems here
NetHandler netHandler = userByNetwork.get(manager);
if (netHandler != null && netHandler.getPlayer() != null) {
String name = netHandler.getPlayer().username;
networkByUser.remove(name);
userByNetwork.remove(manager);
MineTweakerImplementationAPI.events.publishPlayerLoggedOut(
new PlayerLoggedOutEvent(MineTweakerMC.getIPlayer(netHandler.getPlayer())));
}
}
public void openBrowser(String user, String url) {
if (networkByUser.containsKey(user)) {
networkByUser.get(user).addToSendQueue(new Packet250CustomPayload(
MCPacketHandler.CHANNEL_OPENBROWSER,
MCPacketHandler.UTF8.encode(url).array()));
}
}
public void copyToClipboard(String user, String data) {
if (networkByUser.containsKey(user)) {
networkByUser.get(user).addToSendQueue(new Packet250CustomPayload(
MCPacketHandler.CHANNEL_OPENBROWSER,
MCPacketHandler.UTF8.encode(data).array()));
}
}
// ##########################
// ### FML Event Handlers ###
// ##########################
@EventHandler
public void onIMCEvent(FMLInterModComms.IMCEvent event) {
for (final FMLInterModComms.IMCMessage imcMessage : event.getMessages()) {
if (imcMessage.key.equalsIgnoreCase("addMineTweakerScript")) {
if (imcMessage.isStringMessage()) {
scriptsIMC.add(imcMessage.getSender() + "::imc", imcMessage.getStringValue());
} else if (imcMessage.isNBTMessage()) {
NBTTagCompound message = imcMessage.getNBTValue();
scriptsIMC.add(imcMessage.getSender() + "::" + message.getString("name"), message.getString("content"));
}
}
}
}
@EventHandler
public void onLoad(FMLPreInitializationEvent ev) {
}
@EventHandler
public void onPostInit(FMLPostInitializationEvent ev) {
MineTweakerAPI.registerClassRegistry(MineTweakerRegistry.class);
for (int i = 0; i < REGISTRIES.length; i++) {
MineTweakerAPI.registerClassRegistry(REGISTRIES[i], REGISTRY_DESCRIPTIONS[i]);
}
FuelTweaker.INSTANCE.register();
NetworkRegistry.instance().registerConnectionHandler(new MCConnectionHandler());
GameRegistry.registerCraftingHandler(new MTCraftingHandler());
MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());
}
@EventHandler
public void onServerAboutToStart(FMLServerAboutToStartEvent ev) {
// starts before loading worlds
// perfect place to start MineTweaker!
if (MineTweakerPlatformUtils.isClient()) {
MineTweakerAPI.client = new MCClient();
}
File scriptsDir = new File(MineTweakerHacks.getWorldDirectory(ev.getServer()), "scripts");
if (!scriptsDir.exists()) {
scriptsDir.mkdir();
}
IScriptProvider scriptsLocal = new ScriptProviderDirectory(scriptsDir);
IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal, scriptsLocal);
MineTweakerImplementationAPI.setScriptProvider(cascaded);
MineTweakerImplementationAPI.onServerStart(new MCServer(ev.getServer()));
}
@EventHandler
public void onServerStarting(FMLServerStartingEvent ev) {
}
@EventHandler
public void onServerStopped(FMLServerStoppedEvent ev) {
System.out.println("[MineTweaker] Server stopped");
MineTweakerImplementationAPI.onServerStop();
MineTweakerImplementationAPI.setScriptProvider(scriptsGlobal);
}
}
@@ -1,19 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164;
import java.util.List;
/**
*
* @author Stan
*/
public class MineTweakerRegistry {
public static void getClasses(List<Class> classes) {
// method stub, actual content is generated by build process
}
}
@@ -1,66 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.actions;
import java.io.ByteArrayInputStream;
import java.nio.charset.Charset;
import minetweaker.IUndoableAction;
import minetweaker.mc164.util.MineTweakerHacks;
import net.minecraft.util.StringTranslate;
/**
*
* @author Stan
*/
public class SetTranslationAction implements IUndoableAction {
private static final StringTranslate INSTANCE = MineTweakerHacks.getStringTranslateInstance();
private static final Charset UTF8 = Charset.forName("utf-8");
private final String key;
private final String newValue;
private final String oldValue;
public SetTranslationAction(String key, String value) {
this.key = key;
newValue = value;
oldValue = INSTANCE.translateKey(key);
}
@Override
public void apply() {
set(key, newValue);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
set(key, oldValue);
}
@Override
public String describe() {
return "Translating " + key + " to " + newValue;
}
@Override
public String describeUndo() {
return "Reverting " + key + " to " + oldValue;
}
private static void set(String key, String value) {
StringTranslate.inject(new ByteArrayInputStream((key + "=" + value).getBytes(UTF8)));
}
@Override
public Object getOverrideKey() {
return null;
}
}
@@ -1,43 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.block;
import minetweaker.api.block.IBlockDefinition;
import net.minecraft.block.Block;
/**
*
* @author Stan
*/
public class MCBlockDefinition implements IBlockDefinition {
private final Block block;
public MCBlockDefinition(Block block) {
if (block == null)
throw new IllegalArgumentException("block cannot be null");
this.block = block;
}
public Block getInternalBlock() {
return block;
}
public int getInternalId() {
return block.blockID;
}
@Override
public String getId() {
return block.getUnlocalizedName();
}
@Override
public String getDisplayName() {
return block.getLocalizedName();
}
}
@@ -1,88 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.block;
import java.util.Collections;
import java.util.List;
import minetweaker.api.block.BlockPatternOr;
import minetweaker.api.block.IBlock;
import minetweaker.api.block.IBlockDefinition;
import minetweaker.api.block.IBlockPattern;
import minetweaker.api.data.IData;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCItemBlock implements IBlock {
private final ItemStack item;
public MCItemBlock(ItemStack item) {
this.item = item;
}
@Override
public IBlockDefinition getDefinition() {
return MineTweakerMC.getBlockDefinition(Block.blocksList[item.itemID]);
}
@Override
public int getMeta() {
return item.getItemDamage();
}
@Override
public IData getTileData() {
if (item.stackTagCompound == null)
return null;
return MineTweakerMC.getIData(item.stackTagCompound);
}
@Override
public String getDisplayName() {
return item.getDisplayName();
}
@Override
public List<IBlock> getBlocks() {
return Collections.<IBlock>singletonList(this);
}
@Override
public boolean matches(IBlock block) {
/*if (getDefinition() != block.getDefinition()) {
System.out.println("Different block");
return false;
}
if (getMeta() != OreDictionary.WILDCARD_VALUE && getMeta() != block.getMeta()) {
System.out.println("Different meta");
return false;
}
if (getTileData() != null && (block.getTileData() == null || !block.getTileData().contains(getTileData()))) {
System.out.println("Different tile data");
return false;
}
return true;*/
return getDefinition() == block.getDefinition()
&& (getMeta() == OreDictionary.WILDCARD_VALUE || getMeta() == block.getMeta())
&& (getTileData() == null || (block.getTileData() != null && block.getTileData().contains(getTileData())));
}
@Override
public IBlockPattern or(IBlockPattern pattern) {
return new BlockPatternOr(this, pattern);
}
}
@@ -1,78 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.block;
import java.util.Collections;
import java.util.List;
import minetweaker.api.block.BlockPatternOr;
import minetweaker.api.block.IBlock;
import minetweaker.api.block.IBlockDefinition;
import minetweaker.api.block.IBlockPattern;
import minetweaker.api.data.IData;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.block.Block;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCSpecificBlock implements IBlock {
private final Block block;
private final int meta;
public MCSpecificBlock(Block block, int meta) {
this.block = block;
this.meta = meta;
}
@Override
public IBlockDefinition getDefinition() {
return MineTweakerMC.getBlockDefinition(block);
}
@Override
public int getMeta() {
return meta;
}
@Override
public IData getTileData() {
return null;
}
@Override
public List<IBlock> getBlocks() {
return Collections.<IBlock>singletonList(this);
}
@Override
public boolean matches(IBlock block) {
return block.getDefinition() == getDefinition()
&& (meta == OreDictionary.WILDCARD_VALUE || block.getMeta() == meta);
}
@Override
public IBlockPattern or(IBlockPattern pattern) {
return new BlockPatternOr(this, pattern);
}
@Override
public String getDisplayName() {
return block.getLocalizedName();
}
@Override
public String toString() {
return "<block:" + getBlockId(block) + ":" + (meta == OreDictionary.WILDCARD_VALUE ? '*' : meta) + ">";
}
private static String getBlockId(Block block)
{
return block.getUnlocalizedName();
}
}
@@ -1,90 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.block;
import java.util.Collections;
import java.util.List;
import minetweaker.api.block.BlockPatternOr;
import minetweaker.api.block.IBlock;
import minetweaker.api.block.IBlockDefinition;
import minetweaker.api.block.IBlockPattern;
import minetweaker.api.data.IData;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCWorldBlock implements IBlock {
private final IBlockAccess blocks;
private final int x;
private final int y;
private final int z;
public MCWorldBlock(IBlockAccess blocks, int x, int y, int z) {
this.blocks = blocks;
this.x = x;
this.y = y;
this.z = z;
}
@Override
public IBlockDefinition getDefinition() {
return MineTweakerMC.getBlockDefinition(Block.blocksList[blocks.getBlockId(x, y, z)]);
}
@Override
public int getMeta() {
return blocks.getBlockMetadata(x, y, z);
}
@Override
public IData getTileData() {
TileEntity tileEntity = blocks.getBlockTileEntity(x, y, z);
if (tileEntity == null)
return null;
NBTTagCompound nbt = new NBTTagCompound();
tileEntity.writeToNBT(nbt);
return MineTweakerMC.getIData(nbt);
}
@Override
public String getDisplayName() {
int blockId = blocks.getBlockId(x, y, z);
if (Item.itemsList[blockId] != null) {
return (new ItemStack(blockId, 1, getMeta())).getDisplayName();
} else {
return Block.blocksList[blockId].getLocalizedName();
}
}
@Override
public List<IBlock> getBlocks() {
return Collections.<IBlock>singletonList(this);
}
@Override
public boolean matches(IBlock block) {
return getDefinition() == block.getDefinition()
&& (getMeta() == OreDictionary.WILDCARD_VALUE || getMeta() == block.getMeta())
&& (getTileData() == null || (block.getTileData() != null && block.getTileData().contains(getTileData())));
}
@Override
public IBlockPattern or(IBlockPattern pattern) {
return new BlockPatternOr(this, pattern);
}
}
@@ -1,184 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.brackets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import minetweaker.IBracketHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.BracketHandler;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IngredientAny;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStackWildcardSize;
import net.minecraft.item.Item;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.ZenTokener;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionInt;
import stanhebben.zenscript.expression.ExpressionCallStatic;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.type.ZenType;
import stanhebben.zenscript.type.natives.IJavaMethod;
import stanhebben.zenscript.util.ZenPosition;
/**
*
* @author Stan
*/
@BracketHandler(priority=100)
public class ItemBracketHandler implements IBracketHandler {
private static final Map<String, Item> itemNames;
static {
itemNames = new HashMap<String, Item>();
for (Item item : Item.itemsList) {
if (item == null) continue;
itemNames.put(item.getUnlocalizedName().replace(" ", ""), item);
}
}
public static IItemStack getItem(String name, int meta) {
Item item = itemNames.get(name);
if (item != null) {
return getIItemStackWildcardSize(item, meta);
} else {
return null;
}
}
public static IItemStack getItem(int id, int meta) {
Item item = Item.itemsList[id];
if (item != null) {
return getIItemStackWildcardSize(item, meta);
} else {
return null;
}
}
private final IZenSymbol symbolAny;
private final IJavaMethod method;
private final IJavaMethod method2;
public ItemBracketHandler() {
symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(
IngredientAny.class,
"INSTANCE");
method = MineTweakerAPI.getJavaMethod(
ItemBracketHandler.class,
"getItem",
String.class, int.class);
method2 = MineTweakerAPI.getJavaMethod(
ItemBracketHandler.class,
"getItem",
int.class, int.class);
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
// any symbol
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
return symbolAny;
}
// detect special cases:
// item: at the start means item-specific syntax
// :xxx with xxx an integer means sub-item syntax
// :* means any-subitem-syntax
int fromIndex = 0;
int toIndex = tokens.size();
int meta = 0;
if (tokens.size() > 2) {
if (tokens.get(0).getValue().equals("item") && tokens.get(1).getValue().equals(":")) {
fromIndex = 2;
}
if (tokens.get(tokens.size() - 1).getType() == ZenTokener.T_INTVALUE
&& tokens.get(tokens.size() - 2).getValue().equals(":")) {
toIndex = tokens.size() - 2;
meta = Integer.parseInt(tokens.get(tokens.size() - 1).getValue());
} else if (tokens.get(tokens.size() - 1).getValue().equals("*")
&& tokens.get(tokens.size() - 2).getValue().equals(":")) {
toIndex = tokens.size() - 2;
meta = OreDictionary.WILDCARD_VALUE;
}
}
return find(environment, tokens, fromIndex, toIndex, meta);
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex, int meta) {
if (endIndex == startIndex + 1 && tokens.get(startIndex).getType() == ZenTokener.T_INTVALUE) {
int id = Integer.parseInt(tokens.get(startIndex).getValue());
if (id < 0 || id > Item.itemsList.length || Item.itemsList[id] == null) {
return null;
}
return new ItemReferenceSymbolId(environment, id, meta);
}
StringBuilder valueBuilder = new StringBuilder();
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
valueBuilder.append(token.getValue());
}
if (itemNames.containsKey(valueBuilder.toString())) {
return new ItemReferenceSymbol(environment, valueBuilder.toString(), meta);
}
return null;
}
private class ItemReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final String name;
private final int meta;
public ItemReferenceSymbol(IEnvironmentGlobal environment, String name, int meta) {
this.environment = environment;
this.name = name;
this.meta = meta;
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionCallStatic(
position,
environment,
method,
new ExpressionString(position, name),
new ExpressionInt(position, meta, ZenType.INT));
}
}
private class ItemReferenceSymbolId implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final int id;
private final int meta;
public ItemReferenceSymbolId(IEnvironmentGlobal environment, int id, int meta) {
this.environment = environment;
this.id = id;
this.meta = meta;
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionCallStatic(
position,
environment,
method2,
new ExpressionInt(position, id, ZenType.INT),
new ExpressionInt(position, meta, ZenType.INT));
}
}
}
@@ -1,87 +0,0 @@
package minetweaker.mc164.brackets;
import java.util.List;
import minetweaker.IBracketHandler;
import minetweaker.annotations.BracketHandler;
import minetweaker.mc164.liquid.MCLiquidStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.runtime.GlobalRegistry;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionCallStatic;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.type.natives.IJavaMethod;
import stanhebben.zenscript.type.natives.JavaMethod;
import stanhebben.zenscript.util.ZenPosition;
/**
*
* @author Stan
*/
@BracketHandler
public class LiquidBracketHandler implements IBracketHandler {
public static ILiquidStack getLiquid(String name) {
Fluid fluid = FluidRegistry.getFluid(name);
if (fluid != null) {
return new MCLiquidStack(new FluidStack(fluid, 1));
} else {
return null;
}
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
if (tokens.size() > 2) {
if (tokens.get(0).getValue().equals("liquid") && tokens.get(1).getValue().equals(":")) {
return find(environment, tokens, 2, tokens.size());
}
}
return null;
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
StringBuilder valueBuilder = new StringBuilder();
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
valueBuilder.append(token.getValue());
}
Fluid fluid = FluidRegistry.getFluid(valueBuilder.toString());
if (fluid != null) {
return new LiquidReferenceSymbol(environment, valueBuilder.toString());
}
return null;
}
private class LiquidReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final String name;
public LiquidReferenceSymbol(IEnvironmentGlobal environment, String name) {
this.environment = environment;
this.name = name;
}
@Override
public IPartialExpression instance(ZenPosition position) {
IJavaMethod method = JavaMethod.get(
GlobalRegistry.getTypeRegistry(),
LiquidBracketHandler.class,
"getLiquid",
String.class);
return new ExpressionCallStatic(
position,
environment,
method,
new ExpressionString(position, name));
}
}
}
@@ -1,80 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.brackets;
import java.util.List;
import minetweaker.IBracketHandler;
import minetweaker.annotations.BracketHandler;
import static minetweaker.api.minecraft.MineTweakerMC.getOreDict;
import minetweaker.api.oredict.IOreDictEntry;
import minetweaker.runtime.GlobalRegistry;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionCallStatic;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.type.natives.IJavaMethod;
import stanhebben.zenscript.type.natives.JavaMethod;
import stanhebben.zenscript.util.ZenPosition;
/**
*
* @author Stan
*/
@BracketHandler
public class OreBracketHandler implements IBracketHandler {
public static IOreDictEntry getOre(String name) {
return getOreDict(name);
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
if (tokens.size() > 2) {
if (tokens.get(0).getValue().equals("ore") && tokens.get(1).getValue().equals(":")) {
return find(environment, tokens, 2, tokens.size());
}
}
return null;
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
StringBuilder valueBuilder = new StringBuilder();
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
valueBuilder.append(token.getValue());
}
return new OreReferenceSymbol(environment, valueBuilder.toString());
}
private class OreReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final String name;
public OreReferenceSymbol(IEnvironmentGlobal environment, String name) {
this.environment = environment;
this.name = name;
}
@Override
public IPartialExpression instance(ZenPosition position) {
IJavaMethod method = JavaMethod.get(
GlobalRegistry.getTypeRegistry(),
OreBracketHandler.class,
"getOre",
String.class);
return new ExpressionCallStatic(
position,
environment,
method,
new ExpressionString(position, name));
}
}
}
@@ -1,36 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.chat;
import minetweaker.api.chat.IChatMessage;
import net.minecraft.util.ChatMessageComponent;
/**
*
* @author Stan
*/
public class MCChatMessage implements IChatMessage {
private final ChatMessageComponent data;
public MCChatMessage(String message) {
data = ChatMessageComponent.createFromText(message);
}
public MCChatMessage(ChatMessageComponent data) {
this.data = data;
}
@Override
public IChatMessage add(IChatMessage other) {
return new MCChatMessage(data.appendComponent((ChatMessageComponent) other.getInternal()));
}
@Override
public Object getInternal() {
return data;
}
}
@@ -1,29 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.client;
import cpw.mods.fml.client.FMLClientHandler;
import minetweaker.api.client.IClient;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import net.minecraft.client.Minecraft;
/**
*
* @author Stan
*/
public class MCClient implements IClient {
@Override
public IPlayer getPlayer() {
return MineTweakerMC.getIPlayer(Minecraft.getMinecraft().thePlayer);
}
@Override
public String getLanguage() {
return FMLClientHandler.instance().getCurrentLanguage();
}
}
@@ -1,169 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.data;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import minetweaker.mc164.util.MineTweakerHacks;
import minetweaker.api.data.DataByte;
import minetweaker.api.data.DataByteArray;
import minetweaker.api.data.DataDouble;
import minetweaker.api.data.DataFloat;
import minetweaker.api.data.DataInt;
import minetweaker.api.data.DataIntArray;
import minetweaker.api.data.DataList;
import minetweaker.api.data.DataLong;
import minetweaker.api.data.DataMap;
import minetweaker.api.data.DataShort;
import minetweaker.api.data.DataString;
import minetweaker.api.data.IData;
import minetweaker.api.data.IDataConverter;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
/**
*
* @author Stan
*/
public class NBTConverter implements IDataConverter<NBTBase> {
private static final NBTConverter INSTANCE = new NBTConverter();
public static NBTBase from(IData data) {
return data.convert(INSTANCE);
}
public static IData from(NBTBase nbt, boolean immutable) {
if (nbt == null) return null;
switch (nbt.getId()) {
case 1: // byte
return new DataByte(((NBTTagByte) nbt).data);
case 2: // short
return new DataShort(((NBTTagShort) nbt).data);
case 3: // int
return new DataInt(((NBTTagInt) nbt).data);
case 4: // long
return new DataLong(((NBTTagLong) nbt).data);
case 5: // float
return new DataFloat(((NBTTagFloat) nbt).data);
case 6: // double
return new DataDouble(((NBTTagDouble) nbt).data);
case 7: // byte[]
return new DataByteArray(((NBTTagByteArray) nbt).byteArray, immutable);
case 8: // string
return new DataString(((NBTTagString) nbt).data);
case 9: { // list
NBTTagList listTag = (NBTTagList) nbt;
List<IData> values = new ArrayList<IData>();
for (int i = 0; i < listTag.tagCount(); i++) {
values.add(from(listTag.tagAt(i), immutable));
}
return new DataList(values, immutable);
}
case 10: { // compound
Map<String, IData> values = new HashMap<String, IData>();
NBTTagCompound original = (NBTTagCompound) nbt;
Map<String, NBTBase> tagMap = MineTweakerHacks.getNBTCompoundMap(original);
for (String key : tagMap.keySet()) {
values.put(key, from(original.getTag(key), immutable));
}
return new DataMap(values, immutable);
}
case 11: // int[]
return new DataIntArray(((NBTTagIntArray) nbt).intArray, immutable);
default:
throw new RuntimeException("Unknown tag type: " + nbt.getId());
}
}
public static void updateMap(NBTTagCompound nbt, IData data) {
NBTUpdater updater = new NBTUpdater(nbt);
data.convert(updater);
}
public NBTConverter() {}
@Override
public NBTBase fromBool(boolean value) {
return new NBTTagInt(null, value ? 1 : 0);
}
@Override
public NBTBase fromByte(byte value) {
return new NBTTagByte(null, value);
}
@Override
public NBTBase fromShort(short value) {
return new NBTTagShort(null, value);
}
@Override
public NBTBase fromInt(int value) {
return new NBTTagInt(null, value);
}
@Override
public NBTBase fromLong(long value) {
return new NBTTagLong(null, value);
}
@Override
public NBTBase fromFloat(float value) {
return new NBTTagFloat(null, value);
}
@Override
public NBTBase fromDouble(double value) {
return new NBTTagDouble(null, value);
}
@Override
public NBTBase fromString(String value) {
return new NBTTagString(null, value);
}
@Override
public NBTBase fromList(List<IData> values) {
NBTTagList result = new NBTTagList();
for (IData value : values) {
result.appendTag(from(value));
}
return result;
}
@Override
public NBTBase fromMap(Map<String, IData> values) {
NBTTagCompound result = new NBTTagCompound();
for (Map.Entry<String, IData> entry : values.entrySet()) {
result.setTag(entry.getKey(), from(entry.getValue()));
}
return result;
}
@Override
public NBTBase fromByteArray(byte[] value) {
return new NBTTagByteArray(null, value);
}
@Override
public NBTBase fromIntArray(int[] value) {
return new NBTTagIntArray(null, value);
}
}
@@ -1,47 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.data;
import java.util.Map;
import minetweaker.api.data.IData;
import minetweaker.api.data.IDataConverter;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
/**
*
* @author Stan
*/
public class NBTUpdater extends NBTConverter implements IDataConverter<NBTBase> {
private final NBTTagCompound nbt;
public NBTUpdater(NBTTagCompound compound) {
this.nbt = compound;
}
@Override
public NBTBase fromMap(Map<String, IData> map) {
for (Map.Entry<String, IData> entry : map.entrySet()) {
if (nbt.hasKey(entry.getKey())) {
if (entry.getValue() == null) {
nbt.removeTag(entry.getKey());
} else {
if (nbt.getTag(entry.getKey()).getId() == 10) {
NBTTagCompound tag = (NBTTagCompound) nbt.getTag(entry.getKey());
nbt.setTag(entry.getKey(), entry.getValue().convert(new NBTUpdater(nbt)));
} else {
nbt.setTag(entry.getKey(), NBTConverter.from(entry.getValue()));
}
}
} else if (entry.getValue() != null) {
nbt.setTag(entry.getKey(), from(entry.getValue()));
}
}
return nbt;
}
}
@@ -1,32 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.entity;
import cpw.mods.fml.common.registry.EntityRegistry;
import minetweaker.api.entity.IEntityDefinition;
/**
*
* @author Stan
*/
public class MCEntityDefinition implements IEntityDefinition {
private final EntityRegistry.EntityRegistration registration;
public MCEntityDefinition(EntityRegistry.EntityRegistration registration) {
this.registration = registration;
}
@Override
public String getId() {
return registration.getEntityClass().getName();
}
@Override
public String getName() {
return registration.getEntityName();
}
}
@@ -1,44 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.formatting;
import minetweaker.api.formatting.IFormattedText;
import net.minecraft.util.EnumChatFormatting;
/**
*
* @author Stan
*/
public class FormattedMarkupString implements IMCFormattedString {
private final EnumChatFormatting markup;
private final IMCFormattedString contents;
public FormattedMarkupString(EnumChatFormatting markup, IMCFormattedString contents) {
this.markup = markup;
this.contents = contents;
}
@Override
public String getTooltipString() {
return markup + contents.getTooltipString(markup.toString());
}
@Override
public String getTooltipString(String context) {
return markup + contents.getTooltipString(context + markup);
}
@Override
public IFormattedText add(IFormattedText other) {
return cat(other);
}
@Override
public IFormattedText cat(IFormattedText other) {
return new FormattedStringJoin(this, (IMCFormattedString) other);
}
}
@@ -1,41 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.formatting;
import minetweaker.api.formatting.IFormattedText;
/**
*
* @author Stan
*/
public class FormattedString implements IMCFormattedString {
private final String value;
public FormattedString(String value) {
this.value = value;
}
@Override
public String getTooltipString() {
return value;
}
@Override
public String getTooltipString(String context) {
return value;
}
@Override
public IFormattedText add(IFormattedText other) {
return cat(other);
}
@Override
public IFormattedText cat(IFormattedText other) {
return new FormattedStringJoin(this, (IMCFormattedString) other);
}
}
@@ -1,67 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.formatting;
import java.util.Arrays;
import minetweaker.api.formatting.IFormattedText;
import net.minecraft.util.EnumChatFormatting;
/**
*
* @author Stan
*/
public class FormattedStringJoin implements IMCFormattedString {
private final IMCFormattedString[] values;
public FormattedStringJoin(IMCFormattedString first, IMCFormattedString second) {
values = new IMCFormattedString[] { first, second };
}
public FormattedStringJoin(IMCFormattedString[] values) {
this.values = values;
}
@Override
public String getTooltipString() {
StringBuilder result = new StringBuilder();
for (IMCFormattedString value : values) {
result.append(value.getTooltipString());
}
return result.toString();
}
@Override
public String getTooltipString(String context) {
boolean first = true;
StringBuilder result = new StringBuilder();
for (IMCFormattedString value : values) {
if (first) {
first = false;
} else {
result.append(context);
}
result.append(value.getTooltipString());
result.append(EnumChatFormatting.RESET);
}
return result.toString();
}
@Override
public IFormattedText add(IFormattedText other) {
return cat(other);
}
@Override
public IFormattedText cat(IFormattedText other) {
IMCFormattedString[] newValues = Arrays.copyOf(values, values.length + 1);
newValues[values.length] = (IMCFormattedString) other;
return new FormattedStringJoin(newValues);
}
}
@@ -1,19 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.formatting;
import minetweaker.api.formatting.IFormattedText;
/**
*
* @author Stan
*/
public interface IMCFormattedString extends IFormattedText {
public String getTooltipString();
public String getTooltipString(String context);
}
@@ -1,128 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.formatting;
import minetweaker.api.formatting.IFormattedText;
import minetweaker.api.formatting.IFormatter;
import net.minecraft.util.EnumChatFormatting;
/**
*
* @author Stan
*/
public class MCFormatter implements IFormatter {
@Override
public IFormattedText string(String text) {
return new FormattedString(text);
}
@Override
public IFormattedText black(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.BLACK, (IMCFormattedString) text);
}
@Override
public IFormattedText darkBlue(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.DARK_BLUE, (IMCFormattedString) text);
}
@Override
public IFormattedText darkGreen(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.DARK_GREEN, (IMCFormattedString) text);
}
@Override
public IFormattedText darkAqua(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.DARK_AQUA, (IMCFormattedString) text);
}
@Override
public IFormattedText darkRed(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.DARK_RED, (IMCFormattedString) text);
}
@Override
public IFormattedText darkPurple(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.DARK_PURPLE, (IMCFormattedString) text);
}
@Override
public IFormattedText gold(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.GOLD, (IMCFormattedString) text);
}
@Override
public IFormattedText gray(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.GRAY, (IMCFormattedString) text);
}
@Override
public IFormattedText darkGray(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.DARK_GRAY, (IMCFormattedString) text);
}
@Override
public IFormattedText blue(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.BLUE, (IMCFormattedString) text);
}
@Override
public IFormattedText green(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.GREEN, (IMCFormattedString) text);
}
@Override
public IFormattedText aqua(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.AQUA, (IMCFormattedString) text);
}
@Override
public IFormattedText red(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.RED, (IMCFormattedString) text);
}
@Override
public IFormattedText lightPurple(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.LIGHT_PURPLE, (IMCFormattedString) text);
}
@Override
public IFormattedText yellow(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.YELLOW, (IMCFormattedString) text);
}
@Override
public IFormattedText white(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.WHITE, (IMCFormattedString) text);
}
@Override
public IFormattedText obfuscated(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.OBFUSCATED, (IMCFormattedString) text);
}
@Override
public IFormattedText bold(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.BOLD, (IMCFormattedString) text);
}
@Override
public IFormattedText strikethrough(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.STRIKETHROUGH, (IMCFormattedString) text);
}
@Override
public IFormattedText underline(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.UNDERLINE, (IMCFormattedString) text);
}
@Override
public IFormattedText italic(IFormattedText text) {
return new FormattedMarkupString(EnumChatFormatting.ITALIC, (IMCFormattedString) text);
}
}
@@ -1,91 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.furnace;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.IFuelHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
public class FuelTweaker {
public static final FuelTweaker INSTANCE = new FuelTweaker();
private List<IFuelHandler> original;
private final HashMap<String, List<SetFuelPattern>> quickList = new HashMap<String, List<SetFuelPattern>>();
private FuelTweaker() {}
public void register() {
try {
Field fuelHandlers = GameRegistry.class.getDeclaredField("fuelHandlers");
fuelHandlers.setAccessible(true);
original = (List<IFuelHandler>) fuelHandlers.get(null);
List<IFuelHandler> modified = new ArrayList<IFuelHandler>();
modified.add(new OverridingFuelHandler());
fuelHandlers.set(null, modified);
} catch (NoSuchFieldException ex) {
System.out.println("[MineTweaker] Error: could not get GameRegistry fuel handlers field. Cannot use custom fuel values.");
} catch (SecurityException ex) {
System.out.println("[MineTweaker] Error: could not alter GameRegistry fuel handlers field. Cannot use custom fuel values.");
} catch (IllegalAccessException ex) {
System.out.println("[MineTweaker] Error: could not alter GameRegistry fuel handlers field. Cannot use custom fuel values.");
}
}
public void addFuelPattern(SetFuelPattern pattern) {
List<IItemStack> items = pattern.getPattern().getItems();
if (items == null) {
MineTweakerAPI.logError("Cannot set fuel for <*>");
return;
}
for (IItemStack item : pattern.getPattern().getItems()) {
if (!quickList.containsKey(item.getName())) {
quickList.put(item.getName(), new ArrayList<SetFuelPattern>());
}
quickList.get(item.getName()).add(pattern);
}
}
public void removeFuelPattern(SetFuelPattern pattern) {
for (IItemStack item : pattern.getPattern().getItems()) {
if (!quickList.containsKey(item.getName())) {
quickList.put(item.getName(), new ArrayList<SetFuelPattern>());
}
quickList.get(item.getName()).add(pattern);
}
}
private class OverridingFuelHandler implements IFuelHandler {
@Override
public int getBurnTime(ItemStack fuel) {
IItemStack stack = getIItemStack(fuel);
String name = fuel.getUnlocalizedName();
if (quickList.containsKey(name)) {
for (SetFuelPattern override : quickList.get(name)) {
if (override.getPattern().matches(stack)) {
return override.getValue();
}
}
}
int max = 0;
for (IFuelHandler handler : original) {
max = Math.max(max, handler.getBurnTime(fuel));
}
return max;
}
}
}
@@ -1,238 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.furnace;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
import minetweaker.api.recipes.IFurnaceManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCFurnaceManager implements IFurnaceManager {
public MCFurnaceManager() {
}
@Override
public void remove(IIngredient output, IIngredient input) {
if (output == null) throw new IllegalArgumentException("output cannot be null");
Map<Integer, ItemStack> smeltingList = FurnaceRecipes.smelting().getSmeltingList();
Map<List<Integer>, ItemStack> metaSmeltingList = FurnaceRecipes.smelting().getMetaSmeltingList();
List<Integer> toRemove = new ArrayList<Integer>();
List<List<Integer>> toRemoveMeta = new ArrayList<List<Integer>>();
List<ItemStack> toRemoveValues = new ArrayList<ItemStack>();
List<ItemStack> toRemoveMetaValues = new ArrayList<ItemStack>();
for (Map.Entry<Integer, ItemStack> entry : smeltingList.entrySet()) {
if (output.matches(getIItemStack(entry.getValue()))
&& (input == null || input.matches(getIItemStack(new ItemStack(entry.getKey(), 1, 0))))) {
toRemove.add(entry.getKey());
toRemoveValues.add(entry.getValue());
}
}
for (Map.Entry<List<Integer>, ItemStack> entry : metaSmeltingList.entrySet()) {
if (output.matches(getIItemStack(entry.getValue()))
&& (input == null || input.matches(getIItemStack(new ItemStack(entry.getKey().get(0), 1, entry.getKey().get(1)))))) {
toRemoveMeta.add(entry.getKey());
toRemoveMetaValues.add(entry.getValue());
}
}
if (toRemove.isEmpty() && toRemoveMeta.isEmpty()) {
MineTweakerAPI.logWarning("No furnace recipes for " + output.toString());
} else {
MineTweakerAPI.apply(new RemoveAction(toRemove, toRemoveValues, toRemoveMeta, toRemoveMetaValues));
}
}
@Override
public void addRecipe(IItemStack output, IIngredient input, double xp) {
List<IItemStack> items = input.getItems();
if (items == null) {
MineTweakerAPI.logError("Cannot turn " + input.toString() + " into a furnace recipe");
}
ItemStack[] items2 = getItemStacks(items);
ItemStack output2 = getItemStack(output);
MineTweakerAPI.apply(new AddRecipeAction(input, items2, output2, xp));
}
@Override
public void setFuel(IIngredient item, int fuel) {
MineTweakerAPI.apply(new SetFuelAction(new SetFuelPattern(item, fuel)));
}
@Override
public int getFuel(IItemStack item) {
return GameRegistry.getFuelValue(getItemStack(item));
}
// ######################
// ### Action classes ###
// ######################
private static class RemoveAction implements IUndoableAction {
private final List<Integer> items;
private final List<ItemStack> values;
private final List<List<Integer>> metaItems;
private final List<ItemStack> metaValues;
public RemoveAction(List<Integer> items, List<ItemStack> values, List<List<Integer>> metaItems, List<ItemStack> metaValues) {
this.items = items;
this.values = values;
this.metaItems = metaItems;
this.metaValues = metaValues;
}
@Override
public void apply() {
for (Integer item : items) {
FurnaceRecipes.smelting().getSmeltingList().remove(item);
}
for (List<Integer> item : metaItems) {
FurnaceRecipes.smelting().getMetaSmeltingList().remove(item);
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
for (int i = 0; i < items.size(); i++) {
FurnaceRecipes.smelting().getSmeltingList().put(items.get(i), values.get(i));
}
for (int i = 0; i < metaItems.size(); i++) {
FurnaceRecipes.smelting().getMetaSmeltingList().put(metaItems.get(i), metaValues.get(i));
}
}
@Override
public String describe() {
return "Removing " + items.size() + " furnace recipes";
}
@Override
public String describeUndo() {
return "Restoring " + items.size() + " furnace recipes";
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class AddRecipeAction implements IUndoableAction {
private final IIngredient ingredient;
private final ItemStack[] input;
private final ItemStack output;
private final double xp;
public AddRecipeAction(IIngredient ingredient, ItemStack[] input, ItemStack output, double xp) {
this.ingredient = ingredient;
this.input = input;
this.output = output;
this.xp = xp;
}
@Override
public void apply() {
for (ItemStack inputStack : input) {
if (inputStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
FurnaceRecipes.smelting().addSmelting(inputStack.itemID, output, (float) xp);
} else {
FurnaceRecipes.smelting().addSmelting(inputStack.itemID, inputStack.getItemDamage(), output, (float) xp);
}
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
for (ItemStack inputStack : input) {
FurnaceRecipes.smelting().getSmeltingList().remove(inputStack);
}
}
@Override
public String describe() {
return "Adding furnace recipe for " + ingredient;
}
@Override
public String describeUndo() {
return "Removing furnace recipe for " + ingredient;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class SetFuelAction implements IUndoableAction {
private final SetFuelPattern pattern;
public SetFuelAction(SetFuelPattern pattern) {
this.pattern = pattern;
}
@Override
public void apply() {
FuelTweaker.INSTANCE.addFuelPattern(pattern);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
FuelTweaker.INSTANCE.removeFuelPattern(pattern);
}
@Override
public String describe() {
return "Setting fuel for " + pattern.getPattern();
}
@Override
public String describeUndo() {
return "Removing fuel for " + pattern.getPattern();
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,21 +0,0 @@
package minetweaker.mc164.furnace;
import minetweaker.api.item.IIngredient;
public class SetFuelPattern {
private final IIngredient pattern;
private final int value;
public SetFuelPattern(IIngredient pattern, int value) {
this.pattern = pattern;
this.value = value;
}
public IIngredient getPattern() {
return pattern;
}
public int getValue() {
return value;
}
}
@@ -1,184 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.game;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.block.IBlockDefinition;
import minetweaker.api.entity.IEntityDefinition;
import minetweaker.api.game.IGame;
import minetweaker.api.item.IItemDefinition;
import minetweaker.api.liquid.ILiquidDefinition;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.world.IBiome;
import minetweaker.mc164.entity.MCEntityDefinition;
import minetweaker.mc164.item.MCItemDefinition;
import minetweaker.mc164.liquid.MCLiquidDefinition;
import minetweaker.mc164.util.MineTweakerHacks;
import minetweaker.mc164.util.MineTweakerPlatformUtils;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
/**
*
* @author Stan
*/
public class MCGame implements IGame {
private static final Map<String, String> TRANSLATIONS = MineTweakerHacks.getTranslations();
public static final MCGame INSTANCE = new MCGame();
private MCGame() {}
@Override
public List<IItemDefinition> getItems() {
List<IItemDefinition> result = new ArrayList<IItemDefinition>();
for (Item item : Item.itemsList) {
if (item == null) continue;
result.add(new MCItemDefinition(item));
}
return result;
}
@Override
public List<IBlockDefinition> getBlocks() {
List<IBlockDefinition> result = new ArrayList<IBlockDefinition>();
for (Block block : Block.blocksList) {
if (block == null) continue;
result.add(MineTweakerMC.getBlockDefinition(block));
}
return result;
}
@Override
public List<ILiquidDefinition> getLiquids() {
List<ILiquidDefinition> result = new ArrayList<ILiquidDefinition>();
for (Map.Entry<String, Fluid> entry : FluidRegistry.getRegisteredFluids().entrySet()) {
result.add(new MCLiquidDefinition(entry.getValue()));
}
return result;
}
@Override
public List<IBiome> getBiomes() {
List<IBiome> result = new ArrayList<IBiome>();
for (IBiome biome : MineTweakerMC.biomes) {
if (biome != null) {
result.add(biome);
}
}
return result;
}
@Override
public List<IEntityDefinition> getEntities() {
List<IEntityDefinition> result = new ArrayList<IEntityDefinition>();
for (EntityRegistry.EntityRegistration entityRegistration : MineTweakerHacks.getEntityClassRegistrations().values()) {
result.add(new MCEntityDefinition(entityRegistration));
}
return result;
}
@Override
public void setLocalization(String key, String value) {
MineTweakerAPI.apply(new SetTranslation(null, key, value));
}
@Override
public void setLocalization(String lang, String key, String value) {
MineTweakerAPI.apply(new SetTranslation(lang, key, value));
}
@Override
public String localize(String key) {
return LanguageRegistry.instance().getStringLocalization(key);
}
@Override
public String localize(String key, String lang) {
return LanguageRegistry.instance().getStringLocalization(key, lang);
}
// ######################
// ### Action classes ###
// ######################
/**
* Ported from ModTweaker.
*
* @author Joshiejack
*/
private static class SetTranslation implements IUndoableAction {
private String original;
private final String lang;
private final String key;
private final String text;
private boolean added;
public SetTranslation(String lang, String key, String text) {
this.lang = lang;
this.key = key;
this.text = text;
}
@Override
public void apply() {
if (lang == null || MineTweakerPlatformUtils.isLanguageActive(lang)) {
original = TRANSLATIONS.get(key);
TRANSLATIONS.put(key, text);
added = true;
} else {
added = false;
}
}
@Override
public boolean canUndo() {
return TRANSLATIONS != null;
}
@Override
public void undo() {
if (added) {
if (original == null) {
TRANSLATIONS.remove(key);
} else {
TRANSLATIONS.put(key, original);
}
}
}
@Override
public String describe() {
return "Setting localization for the key: " + key + " to " + text;
}
@Override
public String describeUndo() {
return "Setting localization for the key: " + key + " to " + original;
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,87 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.item;
import java.util.ArrayList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemDefinition;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.oredict.IOreDictEntry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCItemDefinition implements IItemDefinition {
private final Item item;
public MCItemDefinition(Item item) {
this.item = item;
}
@Override
public String getId() {
return item.getUnlocalizedName();
}
@Override
public String getName() {
return item.getUnlocalizedName();
}
@Override
public IItemStack makeStack(int meta) {
return MineTweakerMC.getIItemStackWildcardSize(new ItemStack(item, 1, meta));
}
@Override
public List<IOreDictEntry> getOres() {
List<IOreDictEntry> result = new ArrayList<IOreDictEntry>();
for (String key : OreDictionary.getOreNames()) {
for (ItemStack is : OreDictionary.getOres(key)) {
if (is.getItem() == item) {
result.add(MineTweakerAPI.oreDict.get(key));
break;
}
}
}
return result;
}
// #############################
// ### Object implementation ###
// #############################
@Override
public int hashCode() {
int hash = 7;
hash = 37 * hash + (this.item != null ? this.item.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final MCItemDefinition other = (MCItemDefinition) obj;
if (this.item != other.item && (this.item == null || !this.item.equals(other.item))) {
return false;
}
return true;
}
}
@@ -1,374 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.item;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.block.IBlock;
import minetweaker.api.data.DataMap;
import minetweaker.mc164.data.NBTConverter;
import minetweaker.mc164.liquid.MCLiquidStack;
import minetweaker.api.data.IData;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemCondition;
import minetweaker.api.item.IItemDefinition;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IItemTransformer;
import minetweaker.api.item.IngredientItem;
import minetweaker.api.item.IngredientOr;
import minetweaker.api.item.WeightedItemStack;
import minetweaker.api.liquid.ILiquidStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.oredict.IOreDictEntry;
import minetweaker.api.player.IPlayer;
import minetweaker.mc164.actions.SetTranslationAction;
import minetweaker.mc164.block.MCItemBlock;
import minetweaker.util.ArrayUtil;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCItemStack implements IItemStack {
private final ItemStack stack;
private final List<IItemStack> items;
private IData tag = null;
private boolean wildcardSize;
public MCItemStack(ItemStack itemStack) {
if (itemStack == null) throw new IllegalArgumentException("stack cannot be null");
stack = itemStack.copy();
items = Collections.<IItemStack>singletonList(this);
}
public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
this(itemStack);
this.wildcardSize = wildcardSize;
}
private MCItemStack(ItemStack itemStack, IData tag) {
if (itemStack == null) throw new IllegalArgumentException("stack cannot be null");
stack = itemStack;
items = Collections.<IItemStack>singletonList(this);
this.tag = tag;
}
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
stack = itemStack;
items = Collections.<IItemStack>singletonList(this);
this.tag = tag;
this.wildcardSize = wildcardSize;
}
@Override
public IItemDefinition getDefinition() {
return new MCItemDefinition(stack.getItem());
}
@Override
public String getName() {
return stack.getUnlocalizedName();
}
@Override
public String getDisplayName() {
return stack.getDisplayName();
}
@Override
public void setDisplayName(String name) {
MineTweakerAPI.apply(new SetTranslationAction(getName() + ".name", name));
}
@Override
public int getDamage() {
return stack.getItemDamage();
}
@Override
public IData getTag() {
if (tag == null) {
if (stack.stackTagCompound == null) {
return DataMap.EMPTY;
}
tag = NBTConverter.from(stack.stackTagCompound, true);
}
return tag;
}
@Override
public int getMaxDamage() {
return stack.getMaxDamage();
}
@Override
public ILiquidStack getLiquid() {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
return liquid == null ? null : new MCLiquidStack(liquid);
}
@Override
public IIngredient anyDamage() {
if (stack.getItem().getHasSubtypes()) {
MineTweakerAPI.logWarning("subitems don't have damaged states");
return this;
} else {
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, OreDictionary.WILDCARD_VALUE);
result.stackTagCompound = stack.stackTagCompound;
return new MCItemStack(result, tag);
}
}
@Override
public IItemStack withDamage(int damage) {
if (stack.getItem().getHasSubtypes()) {
MineTweakerAPI.logWarning("subitems don't have damaged states");
return this;
} else {
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, damage);
result.stackTagCompound = stack.stackTagCompound;
return new MCItemStack(result, tag);
}
}
@Override
public IItemStack withAmount(int amount) {
ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage());
result.stackTagCompound = stack.stackTagCompound;
return new MCItemStack(result, tag);
}
@Override
public IItemStack anyAmount() {
ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
result.stackTagCompound = stack.stackTagCompound;
return new MCItemStack(result, tag, true);
}
@Override
public IItemStack withTag(IData tag) {
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
if (tag == null) {
result.stackTagCompound = null;
} else {
result.stackTagCompound = (NBTTagCompound) NBTConverter.from(tag);
}
return new MCItemStack(result, tag);
}
@Override
public IItemStack updateTag(IData tagUpdate) {
if (tag == null) {
if (stack.stackTagCompound == null) {
return withTag(tagUpdate);
}
tag = NBTConverter.from(stack.stackTagCompound, true);
}
IData updated = tag.update(tagUpdate);
return withTag(updated);
}
@Override
public String getMark() {
return null;
}
@Override
public int getAmount() {
return stack.stackSize;
}
@Override
public List<IItemStack> getItems() {
return items;
}
@Override
public List<ILiquidStack> getLiquids() {
return Collections.emptyList();
}
@Override
public IItemStack amount(int amount) {
return withAmount(amount);
}
@Override
public WeightedItemStack percent(float chance) {
return new WeightedItemStack(this, chance * 0.01f);
}
@Override
public WeightedItemStack weight(float chance) {
return new WeightedItemStack(this, chance);
}
@Override
public IIngredient transform(IItemTransformer transformer) {
return new IngredientItem(this, null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[] { transformer });
}
@Override
public IIngredient only(IItemCondition condition) {
return new IngredientItem(this, null, new IItemCondition[] { condition }, ArrayUtil.EMPTY_TRANSFORMERS);
}
@Override
public IIngredient marked(String mark) {
return new IngredientItem(this, mark, ArrayUtil.EMPTY_CONDITIONS, ArrayUtil.EMPTY_TRANSFORMERS);
}
@Override
public IIngredient or(IIngredient ingredient) {
return new IngredientOr(this, ingredient);
}
@Override
public boolean matches(IItemStack item) {
if (item == null)
return false;
ItemStack internal = getItemStack(item);
if (internal == null) {
throw new RuntimeException("Invalid item: " + item);
}
return internal.getItem() == stack.getItem()
&& (wildcardSize || internal.stackSize >= stack.stackSize)
&& (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE
|| stack.getItemDamage() == internal.getItemDamage()
|| (!stack.getHasSubtypes() && !stack.getItem().isDamageable()));
}
@Override
public boolean matches(ILiquidStack liquid) {
return false;
}
@Override
public boolean contains(IIngredient ingredient) {
if (ingredient == null)
return false;
List<IItemStack> iitems = ingredient.getItems();
if (iitems == null || iitems.size() != 1) return false;
return matches(iitems.get(0));
}
@Override
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
return item;
}
@Override
public boolean hasTransformers() {
return false;
}
@Override
public IBlock asBlock() {
if (stack.itemID >= Block.blocksList.length || Block.blocksList[stack.itemID] == null) {
throw new ClassCastException("This item is not a block");
} else {
return new MCItemBlock(stack);
}
}
@Override
public Object getInternal() {
return stack;
}
@Override
public List<IOreDictEntry> getOres() {
List<IOreDictEntry> result = new ArrayList<IOreDictEntry>();
for (String key : OreDictionary.getOreNames()) {
for (ItemStack is : OreDictionary.getOres(key)) {
if (is.getItem() == stack.getItem()
&& (is.getItemDamage() == OreDictionary.WILDCARD_VALUE || is.getItemDamage() == stack.getItemDamage())) {
result.add(MineTweakerAPI.oreDict.get(key));
break;
}
}
}
return result;
}
// #############################
// ### Object implementation ###
// #############################
@Override
public int hashCode() {
int hash = 7;
hash = 41 * hash + stack.itemID;
hash = 41 * hash + stack.getItemDamage();
hash = 41 * hash + stack.stackSize;
hash = 41 * hash + (stack.stackTagCompound == null ? 0 : stack.stackTagCompound.hashCode());
hash = 41 * hash + (this.wildcardSize ? 1 : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final MCItemStack other = (MCItemStack) obj;
if (this.stack.itemID != other.stack.itemID) return false;
if (this.stack.getItemDamage() != other.stack.getItemDamage()) return false;
if (this.stack.stackSize != other.stack.stackSize) return false;
if (this.stack.stackTagCompound != other.stack.stackTagCompound && (this.stack == null || this.stack.equals(other.stack))) return false;
if (this.wildcardSize != other.wildcardSize) return false;
return true;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append('<');
result.append(stack.getItem().getUnlocalizedName());
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
result.append(":*");
} else if (stack.getItemDamage() > 0) {
result.append(':').append(stack.getItemDamage());
}
result.append('>');
if (stack.getTagCompound() != null) {
result.append(".withTag(");
result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString());
result.append(")");
}
if (!wildcardSize) {
result.append(" * ").append(stack.stackSize);
}
return result.toString();
}
}
@@ -1,441 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.liquid;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidDefinition;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.mc164.util.MineTweakerHacks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidStack;
/**
*
* @author Stan
*/
public class MCLiquidDefinition implements ILiquidDefinition {
private static final Map<List, FluidContainerData> containerFluidMap = MineTweakerHacks.getFluidContainerMap();
private static final Map<List, FluidContainerData> filledContainerMap = MineTweakerHacks.getFilledContainerMap();
private static final Set<List> emptyContainers = MineTweakerHacks.getEmptyContainers();
private final Fluid fluid;
public MCLiquidDefinition(Fluid fluid) {
this.fluid = fluid;
}
@Override
public String getName() {
return fluid.getName();
}
@Override
public String getDisplayName() {
return fluid.getLocalizedName();
}
@Override
public ILiquidStack asStack(int millibuckets) {
return new MCLiquidStack(new FluidStack(fluid, millibuckets));
}
@Override
public int getLuminosity() {
return fluid.getLuminosity();
}
@Override
public void setLuminosity(int value) {
MineTweakerAPI.apply(new ActionSetLuminosity(value));
}
@Override
public int getDensity() {
return fluid.getDensity();
}
@Override
public void setDensity(int density) {
MineTweakerAPI.apply(new ActionSetDensity(density));
}
@Override
public int getTemperature() {
return fluid.getTemperature();
}
@Override
public void setTemperature(int temperature) {
MineTweakerAPI.apply(new ActionSetTemperature(temperature));
}
@Override
public int getViscosity() {
return fluid.getViscosity();
}
@Override
public void setViscosity(int viscosity) {
MineTweakerAPI.apply(new ActionSetViscosity(viscosity));
}
@Override
public boolean isGaseous() {
return fluid.isGaseous();
}
@Override
public void setGaseous(boolean gaseous) {
MineTweakerAPI.apply(new ActionSetGaseous(gaseous));
}
@Override
public List<IItemStack> getContainers() {
List<IItemStack> result = new ArrayList<IItemStack>();
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.fluid.getFluid() == fluid) {
result.add(MineTweakerMC.getIItemStack(data.filledContainer));
}
}
return result;
}
@Override
public void addContainer(IItemStack filled, IItemStack empty, int amount) {
MineTweakerAPI.apply(new AddContainerAction(filled, empty, amount));
}
@Override
public void removeContainer(IItemStack filled) {
MineTweakerAPI.apply(new RemoveContainerAction(filled));
}
// #######################
// ### Private methods ###
// #######################
private void removeContainerInner(IItemStack filled) {
ItemStack filledItem = MineTweakerMC.getItemStack(filled);
FluidContainerData data = filledContainerMap.get(Arrays.asList(filledItem.itemID, filledItem.getItemDamage()));
if (data != null) {
filledContainerMap.remove(Arrays.asList(filledItem.itemID, filledItem.getItemDamage()));
containerFluidMap.remove(Arrays.asList(data.emptyContainer.itemID, data.emptyContainer.getItemDamage()));
// rebuild empty containers set
emptyContainers.clear();
for (FluidContainerData fdata : filledContainerMap.values()) {
emptyContainers.add(Arrays.asList(fdata.emptyContainer.itemID, fdata.emptyContainer.getItemDamage()));
}
}
}
private FluidContainerData getData(IItemStack filled) {
ItemStack filledStack = MineTweakerMC.getItemStack(filled);
return filledContainerMap.get(Arrays.asList(filledStack.itemID, filledStack.getItemDamage()));
}
// ######################
// ### Action classes ###
// ######################
private class AddContainerAction implements IUndoableAction {
private final IItemStack filled;
private final IItemStack empty;
private final int amount;
public AddContainerAction(IItemStack filled, IItemStack empty, int amount) {
this.filled = filled;
this.empty = empty;
this.amount = amount;
}
@Override
public void apply() {
FluidContainerRegistry.registerFluidContainer(new FluidStack(fluid, amount), MineTweakerMC.getItemStack(filled), MineTweakerMC.getItemStack(empty));
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
removeContainerInner(filled);
}
@Override
public String describe() {
return "Adding " + filled.getDisplayName() + " as liquid container for " + fluid.getLocalizedName();
}
@Override
public String describeUndo() {
return "Removing liquid container " + filled;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class RemoveContainerAction implements IUndoableAction {
private final IItemStack filled;
private final IItemStack empty;
private final FluidStack amount;
public RemoveContainerAction(IItemStack filled) {
this.filled = filled;
FluidContainerData data = getData(filled);
empty = MineTweakerMC.getIItemStack(data.emptyContainer);
amount = data.fluid;
}
@Override
public void apply() {
removeContainerInner(filled);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
FluidContainerRegistry.registerFluidContainer(amount, MineTweakerMC.getItemStack(filled), MineTweakerMC.getItemStack(empty));
}
@Override
public String describe() {
return "Removing liquid container " + filled;
}
@Override
public String describeUndo() {
return "Restoring liquid container " + filled;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class ActionSetLuminosity implements IUndoableAction {
private final int oldValue;
private final int newValue;
public ActionSetLuminosity(int newValue) {
oldValue = getLuminosity();
this.newValue = newValue;
}
@Override
public void apply() {
fluid.setLuminosity(newValue);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
fluid.setLuminosity(oldValue);
}
@Override
public String describe() {
return "Setting " + fluid.getName() + " luminosity to " + newValue;
}
@Override
public String describeUndo() {
return "Restoring " + fluid.getName() + " luminosity to " + oldValue;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class ActionSetDensity implements IUndoableAction {
private final int oldValue;
private final int newValue;
public ActionSetDensity(int newValue) {
oldValue = getDensity();
this.newValue = newValue;
}
@Override
public void apply() {
fluid.setDensity(newValue);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
fluid.setDensity(oldValue);
}
@Override
public String describe() {
return "Setting " + fluid.getName() + " density to " + newValue;
}
@Override
public String describeUndo() {
return "Restoring " + fluid.getName() + " density to " + oldValue;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class ActionSetTemperature implements IUndoableAction {
private final int oldValue;
private final int newValue;
public ActionSetTemperature(int newValue) {
oldValue = getTemperature();
this.newValue = newValue;
}
@Override
public void apply() {
fluid.setTemperature(newValue);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
fluid.setTemperature(oldValue);
}
@Override
public String describe() {
return "Setting " + fluid.getName() + " temperature to " + newValue;
}
@Override
public String describeUndo() {
return "Restoring " + fluid.getName() + " temperature to " + oldValue;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class ActionSetViscosity implements IUndoableAction {
private final int oldValue;
private final int newValue;
public ActionSetViscosity(int newValue) {
oldValue = getViscosity();
this.newValue = newValue;
}
@Override
public void apply() {
fluid.setViscosity(newValue);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
fluid.setViscosity(oldValue);
}
@Override
public String describe() {
return "Setting " + fluid.getName() + " viscosity to " + newValue;
}
@Override
public String describeUndo() {
return "Restoring " + fluid.getName() + " viscosity to " + oldValue;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class ActionSetGaseous implements IUndoableAction {
private final boolean oldValue;
private final boolean newValue;
public ActionSetGaseous(boolean newValue) {
oldValue = isGaseous();
this.newValue = newValue;
}
@Override
public void apply() {
fluid.setGaseous(newValue);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
fluid.setGaseous(oldValue);
}
@Override
public String describe() {
return "Setting " + fluid.getName() + " gaseous to " + newValue;
}
@Override
public String describeUndo() {
return "Restoring " + fluid.getName() + " gaseous to " + oldValue;
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,209 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.liquid;
import java.util.Collections;
import java.util.List;
import minetweaker.mc164.data.NBTConverter;
import minetweaker.api.data.IData;
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.ILiquidDefinition;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.player.IPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
/**
*
* @author Stan
*/
public class MCLiquidStack implements ILiquidStack {
private final FluidStack stack;
private IData tag = null;
public MCLiquidStack(FluidStack stack) {
this.stack = stack;
}
private MCLiquidStack(FluidStack stack, IData tag) {
this.stack = stack;
this.tag = tag;
}
@Override
public ILiquidDefinition getDefinition() {
return new MCLiquidDefinition(stack.getFluid());
}
@Override
public String getName() {
return stack.getFluid().getName();
}
@Override
public String getDisplayName() {
return stack.getFluid().getLocalizedName();
}
@Override
public int getAmount() {
return stack.amount;
}
@Override
public IData getTag() {
if (tag == null) {
if (stack.tag == null) {
return null;
}
tag = NBTConverter.from(stack.tag, true);
}
return tag;
}
@Override
public ILiquidStack withTag(IData data) {
FluidStack result = new FluidStack(stack.fluidID, stack.amount);
result.tag = (NBTTagCompound) NBTConverter.from(data);
return new MCLiquidStack(result, data.immutable());
}
@Override
public ILiquidStack withAmount(int amount) {
FluidStack result = new FluidStack(stack.fluidID, amount);
result.tag = stack.tag;
return new MCLiquidStack(result, tag);
}
@Override
public int getLuminosity() {
return stack.getFluid().getLuminosity(stack);
}
@Override
public int getDensity() {
return stack.getFluid().getDensity(stack);
}
@Override
public int getTemperature() {
return stack.getFluid().getTemperature(stack);
}
@Override
public int getViscosity() {
return stack.getFluid().getViscosity(stack);
}
@Override
public boolean isGaseous() {
return stack.getFluid().isGaseous(stack);
}
@Override
public Object getInternal() {
return stack;
}
// ##################################
// ### IIngredient implementation ###
// ##################################
@Override
public String getMark()
{
return null;
}
@Override
public List<IItemStack> getItems()
{
return Collections.emptyList();
}
@Override
public List<ILiquidStack> getLiquids()
{
return Collections.<ILiquidStack>singletonList(this);
}
@Override
public IIngredient amount(int amount)
{
return withAmount(amount);
}
@Override
public IIngredient or(IIngredient ingredient)
{
return new IngredientOr(this, ingredient);
}
@Override
public IIngredient transform(IItemTransformer transformer)
{
throw new UnsupportedOperationException("Liquid stack can't have transformers");
}
@Override
public IIngredient only(IItemCondition condition)
{
throw new UnsupportedOperationException("Liquid stack can't have conditions");
}
@Override
public IIngredient marked(String mark)
{
throw new UnsupportedOperationException("Liquid stack can't be marked");
}
@Override
public boolean matches(IItemStack item)
{
return false;
}
@Override
public boolean matches(ILiquidStack liquid)
{
return getDefinition().equals(liquid.getDefinition())
&& getAmount() <= liquid.getAmount();
}
@Override
public boolean contains(IIngredient ingredient)
{
if (!ingredient.getItems().isEmpty())
return false;
for (ILiquidStack liquid : ingredient.getLiquids())
{
if (!matches(liquid))
return false;
}
return false;
}
@Override
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer)
{
return item;
}
@Override
public boolean hasTransformers()
{
return false;
}
}
@@ -1,44 +0,0 @@
package minetweaker.mc164.mods;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import java.util.Iterator;
import java.util.List;
import minetweaker.api.mods.ILoadedMods;
import minetweaker.api.mods.IMod;
import stanhebben.zenscript.util.MappingIterator;
/**
*
* @author Stan
*/
public class MCLoadedMods implements ILoadedMods {
public MCLoadedMods() {}
@Override
public boolean contains(String name) {
return Loader.isModLoaded(name);
}
@Override
public IMod get(String name) {
for (ModContainer mod : Loader.instance().getActiveModList()) {
if (mod.getModId().equals(name)) {
return new MCMod(mod);
}
}
return null;
}
@Override
public Iterator<IMod> iterator() {
List<ModContainer> mods = Loader.instance().getActiveModList();
return new MappingIterator<ModContainer, IMod>(mods.iterator()) {
@Override
public IMod map(ModContainer value) {
return new MCMod(value);
}
};
}
}
@@ -1,42 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.mods;
import cpw.mods.fml.common.ModContainer;
import minetweaker.api.mods.IMod;
/**
*
* @author Stan
*/
public class MCMod implements IMod {
private final ModContainer mod;
public MCMod(ModContainer mod) {
this.mod = mod;
}
@Override
public String getId() {
return mod.getModId();
}
@Override
public String getName() {
return mod.getName();
}
@Override
public String getVersion() {
return mod.getVersion();
}
@Override
public String getDescription() {
return mod.getMetadata().description;
}
}
@@ -1,61 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.network;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.Player;
import minetweaker.MineTweakerAPI;
import minetweaker.mc164.MineTweakerMod;
public class MCConnectionHandler implements IConnectionHandler {
@Override
public void playerLoggedIn(Player player, NetHandler netHandler,
INetworkManager manager) {
System.out.println("Player logged in: " + netHandler.getPlayer().username);
byte[] scriptData = MineTweakerAPI.tweaker.getScriptData();
System.out.println("Sending script data: " + scriptData.length + " bytes");
manager.addToSendQueue(new Packet250CustomPayload(
MCPacketHandler.CHANNEL_SERVERSCRIPT,
MineTweakerAPI.tweaker.getScriptData()));
MineTweakerMod.INSTANCE.onPlayerLogin(player, netHandler, manager);
}
@Override
public String connectionReceived(NetLoginHandler netHandler,
INetworkManager manager) {
return null;
}
@Override
public void connectionOpened(NetHandler netClientHandler, String server,
int port, INetworkManager manager) {
}
@Override
public void connectionOpened(NetHandler netClientHandler,
MinecraftServer server, INetworkManager manager) {
}
@Override
public void connectionClosed(INetworkManager manager) {
MineTweakerMod.INSTANCE.onPlayerLogout(manager);
}
@Override
public void clientLoggedIn(NetHandler clientHandler,
INetworkManager manager, Packet1Login login) {
}
}
@@ -1,70 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.network;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import java.awt.Desktop;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.mc164.client.MCClient;
import minetweaker.runtime.providers.ScriptProviderMemory;
public class MCPacketHandler implements IPacketHandler {
public static final Charset UTF8 = Charset.forName("utf-8");
public static final String CHANNEL_SERVERSCRIPT = "MTServerScript";
public static final String CHANNEL_OPENBROWSER = "MTOpenBrowser";
public static final String CHANNEL_COPYTOCLIPBOARD = "MTCopyToClipboard";
@Override
public void onPacketData(INetworkManager manager,
Packet250CustomPayload packet, Player player) {
// catches some special cases caused by unknown reasons
if (packet == null || packet.channel == null || packet.data == null) return;
if (packet.channel.equals(CHANNEL_SERVERSCRIPT)) {
System.out.println("Received script data: " + packet.data.length + " bytes");
if (MineTweakerAPI.server == null) {
MineTweakerAPI.client = new MCClient();
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderMemory(packet.data));
MineTweakerImplementationAPI.reload();
}
} else if (packet.channel.equals(CHANNEL_OPENBROWSER)) {
String url = UTF8.decode(ByteBuffer.wrap(packet.data)).toString().trim();
if (Desktop.isDesktopSupported()){
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(url));
} catch (IOException e) {
} catch (URISyntaxException e) {
}
}
} else if (packet.channel.equals(CHANNEL_COPYTOCLIPBOARD)) {
String message = UTF8.decode(ByteBuffer.wrap(packet.data)).toString().trim();
if (Desktop.isDesktopSupported()) {
StringSelection stringSelection = new StringSelection(message);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
}
}
}
@@ -1,37 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.oredict;
import java.util.ArrayList;
import java.util.List;
import minetweaker.api.minecraft.MineTweakerMC;
import static minetweaker.api.minecraft.MineTweakerMC.getOreDict;
import minetweaker.api.oredict.IOreDict;
import minetweaker.api.oredict.IOreDictEntry;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCOreDict implements IOreDict {
@Override
public IOreDictEntry get(String name) {
return getOreDict(name);
}
@Override
public List<IOreDictEntry> getEntries() {
List<IOreDictEntry> entries = new ArrayList<IOreDictEntry>();
for (String key : OreDictionary.getOreNames()) {
if (!OreDictionary.getOres(key).isEmpty()) {
entries.add(MineTweakerMC.getOreDict(key));
}
}
return entries;
}
}
@@ -1,391 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.oredict;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.mc164.util.MineTweakerHacks;
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.item.IngredientStack;
import minetweaker.api.liquid.ILiquidStack;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStackWildcardSize;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.oredict.IOreDictEntry;
import minetweaker.api.oredict.IngredientOreDict;
import minetweaker.api.player.IPlayer;
import minetweaker.util.ArrayUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
/**
*
* @author Stan
*/
public class MCOreDictEntry implements IOreDictEntry {
private final int id;
public MCOreDictEntry(Integer id) {
this.id = id;
}
public MCOreDictEntry(String id) {
this.id = OreDictionary.getOreID(id);
}
// ####################################
// ### IOreDictEntry implementation ###
// ####################################
@Override
public String getName() {
return OreDictionary.getOreName(id);
}
@Override
public boolean isEmpty() {
return OreDictionary.getOres(id).isEmpty();
}
@Override
public void add(IItemStack item) {
ItemStack stack = getItemStack(item);
if (stack == null) {
MineTweakerAPI.logError("not a valid item");
} else {
MineTweakerAPI.apply(new ActionAddItem(id, stack));
}
}
@Override
public void addAll(IOreDictEntry entry) {
if (entry instanceof MCOreDictEntry) {
MineTweakerAPI.apply(new ActionAddAll(id, ((MCOreDictEntry) entry).id));
} else {
MineTweakerAPI.logError("not a valid entry");
}
}
@Override
public void remove(IItemStack item) {
ItemStack result = null;
for (ItemStack itemStack : OreDictionary.getOres(id)) {
if (item.matches(getIItemStackWildcardSize(itemStack))) {
result = itemStack;
break;
}
}
if (result != null) {
MineTweakerAPI.apply(new ActionRemoveItem(id, result));
}
}
@Override
public boolean contains(IItemStack item) {
for (ItemStack itemStack : OreDictionary.getOres(id)) {
if (getIItemStackWildcardSize(itemStack).matches(item)) {
return true;
}
}
return false;
}
@Override
public void mirror(IOreDictEntry other) {
if (other instanceof MCOreDictEntry) {
MineTweakerAPI.apply(new ActionMirror(id, ((MCOreDictEntry) other).id));
} else {
MineTweakerAPI.logError("not a valid oredict entry");
}
}
@Override
public String getMark() {
return null;
}
@Override
public int getAmount() {
return 1;
}
@Override
public List<IItemStack> getItems() {
List<IItemStack> result = new ArrayList<IItemStack>();
for (ItemStack item : OreDictionary.getOres(id)) {
result.add(getIItemStackWildcardSize(item));
}
return result;
}
@Override
public List<ILiquidStack> getLiquids() {
return Collections.emptyList();
}
@Override
public IIngredient amount(int amount) {
return new IngredientStack(this, amount);
}
@Override
public IIngredient transform(IItemTransformer transformer) {
return new IngredientOreDict(this, null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[] { transformer });
}
@Override
public IIngredient only(IItemCondition condition) {
return new IngredientOreDict(this, null, new IItemCondition[] { condition }, ArrayUtil.EMPTY_TRANSFORMERS);
}
@Override
public IIngredient marked(String mark) {
return new IngredientOreDict(this, mark, ArrayUtil.EMPTY_CONDITIONS, ArrayUtil.EMPTY_TRANSFORMERS);
}
@Override
public IIngredient or(IIngredient ingredient) {
return new IngredientOr(this, ingredient);
}
@Override
public boolean matches(IItemStack item) {
return contains(item);
}
@Override
public boolean matches(ILiquidStack liquid) {
return false;
}
@Override
public boolean contains(IIngredient ingredient) {
List<IItemStack> items = ingredient.getItems();
for (IItemStack item : items) {
if (!matches(item)) return false;
}
return true;
}
@Override
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
return item;
}
@Override
public boolean hasTransformers() {
return false;
}
@Override
public Object getInternal() {
return OreDictionary.getOreName(id);
}
// #############################
// ### Object implementation ###
// #############################
@Override
public String toString() {
return "<ore:" + OreDictionary.getOreName(id) + ">";
}
@Override
public int hashCode() {
return id;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof MCOreDictEntry)) return false;
return ((MCOreDictEntry) other).id == id;
}
// ######################
// ### Action classes ###
// ######################
private static class ActionAddItem implements IUndoableAction {
private final Integer id;
private final ItemStack item;
public ActionAddItem(Integer id, ItemStack item) {
this.id = id;
this.item = item;
}
@Override
public void apply() {
OreDictionary.registerOre(id, item);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
OreDictionary.getOres(id).remove(item);
}
@Override
public String describe() {
return "Adding " + item.getDisplayName() + " to ore dictionary entry " + OreDictionary.getOreName(id);
}
@Override
public String describeUndo() {
return "Removing " + item.getDisplayName() + " from ore dictionary entry " + OreDictionary.getOreName(id);
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class ActionMirror implements IUndoableAction {
private final Integer idTarget;
private final Integer idSource;
private final ArrayList<ItemStack> targetCopy;
public ActionMirror(Integer idTarget, Integer idSource) {
this.idTarget = idTarget;
this.idSource = idSource;
targetCopy = OreDictionary.getOres(idTarget);
}
@Override
public void apply() {
MineTweakerHacks.getOreStacks().put(idTarget, OreDictionary.getOres(idSource));
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
MineTweakerHacks.getOreStacks().put(idTarget, targetCopy);
}
@Override
public String describe() {
return "Mirroring " + OreDictionary.getOreName(idSource) + " to " + OreDictionary.getOreName(idTarget);
}
@Override
public String describeUndo() {
return "Undoing mirror of " + OreDictionary.getOreName(idSource) + " to " + OreDictionary.getOreName(idTarget);
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class ActionRemoveItem implements IUndoableAction {
private final Integer id;
private final ItemStack item;
public ActionRemoveItem(Integer id, ItemStack item) {
this.id = id;
this.item = item;
}
@Override
public void apply() {
OreDictionary.getOres(id).remove(item);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
OreDictionary.getOres(id).add(item);
}
@Override
public String describe() {
return "Removing " + item.getDisplayName() + " from ore dictionary entry " + OreDictionary.getOreName(id);
}
@Override
public String describeUndo() {
return "Restoring " + item.getDisplayName() + " to ore dictionary entry " + OreDictionary.getOreName(id);
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class ActionAddAll implements IUndoableAction {
private final Integer idTarget;
private final Integer idSource;
public ActionAddAll(Integer idTarget, Integer idSource) {
this.idTarget = idTarget;
this.idSource = idSource;
}
@Override
public void apply() {
List<ItemStack> ores = OreDictionary.getOres(idTarget);
for (ItemStack stack : OreDictionary.getOres(idSource)) {
ores.add(stack);
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
List<ItemStack> ores = OreDictionary.getOres(idTarget);
for (ItemStack stack : OreDictionary.getOres(idSource)) {
ores.remove(stack);
}
}
@Override
public String describe() {
return "Copying contents of ore dictionary entry " + OreDictionary.getOreName(idSource) + " to " + OreDictionary.getOreName(idTarget);
}
@Override
public String describeUndo() {
return "Removing contents of ore dictionary entry " + OreDictionary.getOreName(idSource) + " from " + OreDictionary.getOreName(idTarget);
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,147 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.player;
import minetweaker.MineTweakerAPI;
import minetweaker.api.chat.IChatMessage;
import minetweaker.mc164.data.NBTConverter;
import minetweaker.api.data.IData;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import minetweaker.mc164.MineTweakerMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatMessageComponent;
/**
*
* @author Stan
*/
public class MCPlayer implements IPlayer {
private final EntityPlayer player;
public MCPlayer(EntityPlayer player) {
this.player = player;
}
public EntityPlayer getInternal() {
return player;
}
@Override
public String getId() {
return null;
}
@Override
public String getName() {
return player.getCommandSenderName();
}
@Override
public IData getData() {
return NBTConverter.from(player.getEntityData(), true);
}
@Override
public void update(IData data) {
NBTConverter.updateMap(player.getEntityData(), data);
}
@Override
public void sendChat(IChatMessage message) {
Object internal = message.getInternal();
if (!(internal instanceof ChatMessageComponent)) {
//throw new RuntimeException("Not a valid chat message: " + internal);
MineTweakerAPI.logError("not a valid chat message");
return;
}
player.sendChatToPlayer((ChatMessageComponent) internal);
}
@Override
public void sendChat(String message) {
player.sendChatToPlayer(ChatMessageComponent.createFromText(message));
}
@Override
public int getHotbarSize() {
return 9;
}
@Override
public IItemStack getHotbarStack(int i) {
return i < 0 || i >= 9 ? null : MineTweakerMC.getIItemStack(player.inventory.getStackInSlot(i));
}
@Override
public int getInventorySize() {
return player.inventory.getSizeInventory();
}
@Override
public IItemStack getInventoryStack(int i) {
return MineTweakerMC.getIItemStack(player.inventory.getStackInSlot(i));
}
@Override
public IItemStack getCurrentItem() {
return MineTweakerMC.getIItemStack(player.getCurrentEquippedItem());
}
@Override
public boolean isCreative() {
return player.capabilities.isCreativeMode;
}
@Override
public boolean isAdventure() {
return !player.capabilities.allowEdit;
}
@Override
public void openBrowser(String url) {
if (player instanceof EntityPlayerMP) {
MineTweakerMod.INSTANCE.openBrowser(player.username, url);
}
}
@Override
public void copyToClipboard(String value) {
if (player instanceof EntityPlayerMP) {
MineTweakerMod.INSTANCE.copyToClipboard(player.username, value);
}
}
@Override
public void give(IItemStack stack) {
player.inventory.addItemStackToInventory(MineTweakerMC.getItemStack(stack).copy());
}
@Override
public int hashCode() {
int hash = 3;
hash = 59 * hash + (this.player != null ? this.player.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final MCPlayer other = (MCPlayer) obj;
if (this.player != other.player && (this.player == null || !this.player.equals(other.player))) {
return false;
}
return true;
}
}
@@ -1,207 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import java.util.List;
import minetweaker.mc164.util.MineTweakerHacks;
import minetweaker.api.item.IItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.player.IPlayer;
import minetweaker.api.recipes.ICraftingInventory;
import minetweaker.mc164.player.MCPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
/**
*
* @author Stan
*/
public class MCCraftingInventory implements ICraftingInventory {
private static final ThreadLocal<MCCraftingInventory> cache = new ThreadLocal<MCCraftingInventory>();
private static final ThreadLocal<MCCraftingInventory> cache2 = new ThreadLocal<MCCraftingInventory>();
public static MCCraftingInventory get(InventoryCrafting inventory) {
if (cache.get() == null || cache.get().inventory != inventory) {
MCCraftingInventory result = new MCCraftingInventory(inventory);
cache.set(result);
return result;
} else {
MCCraftingInventory result = cache.get();
result.update();
return result;
}
}
public static MCCraftingInventory get(IInventory inventory, EntityPlayer player) {
if (cache2.get() == null || cache2.get().inventory != inventory || cache2.get().player != player) {
MCCraftingInventory result = new MCCraftingInventory(inventory, player);
cache2.set(result);
return result;
} else {
MCCraftingInventory result = cache2.get();
result.update();
return result;
}
}
private int width;
private int height;
private final IInventory inventory;
private IItemStack[] stacks;
private ItemStack[] original;
private int stackCount;
private final IPlayer player;
private final EntityPlayer playerOrig;
private MCCraftingInventory(InventoryCrafting inventory) {
this.inventory = inventory;
width = height = (int) Math.sqrt(inventory.getSizeInventory());
stacks = new IItemStack[width * height];
original = new ItemStack[stacks.length];
stackCount = 0;
update();
Container container = MineTweakerHacks.getCraftingContainer(inventory);
if (container != null) {
List<Slot> slots = container.inventorySlots;
if (!slots.isEmpty() && slots.get(0) instanceof SlotCrafting) {
SlotCrafting slotCrafting = (SlotCrafting) slots.get(0);
playerOrig = MineTweakerHacks.getCraftingSlotPlayer(slotCrafting);
player = new MCPlayer(playerOrig);
} else {
playerOrig = null;
player = null;
}
} else {
playerOrig = null;
player = null;
}
}
public MCCraftingInventory(IInventory inventory, EntityPlayer player) {
this.inventory = inventory;
width = height = (int) Math.sqrt(inventory.getSizeInventory());
stacks = new IItemStack[width * height];
original = new ItemStack[stacks.length];
stackCount = 0;
update();
playerOrig = player;
this.player = player == null ? null : new MCPlayer(player);
}
private void update() {
if (inventory.getSizeInventory() != original.length) {
width = height = (int) Math.sqrt(inventory.getSizeInventory());
stacks = new IItemStack[inventory.getSizeInventory()];
original = new ItemStack[stacks.length];
stackCount = 0;
}
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (changed(i)) {
//System.out.println("Slot " + i + " changed");
original[i] = inventory.getStackInSlot(i);
if (inventory.getStackInSlot(i) != null) {
if (stacks[i] == null) stackCount++;
stacks[i] = getIItemStack(original[i]);
} else {
if (stacks[i] != null) stackCount--;
stacks[i] = null;
}
}
}
//System.out.println("Num stack count: " + stackCount);
}
@Override
public IPlayer getPlayer() {
return player;
}
@Override
public int getSize() {
return width * height;
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public int getStackCount() {
return stackCount;
}
@Override
public IItemStack getStack(int i) {
return stacks[i];
}
@Override
public IItemStack getStack(int x, int y) {
return stacks[y * width + x];
}
@Override
public void setStack(int x, int y, IItemStack stack) {
//System.out.println("SetStack(" + x + ", " + y + ") " + stack);
int ix = y * width + x;
if (stack != stacks[ix]) {
if (stack == null) {
stackCount--;
inventory.setInventorySlotContents(ix, null);
} else {
inventory.setInventorySlotContents(ix, getItemStack(stack));
if (stacks[ix] == null) {
stackCount++;
}
}
stacks[ix] = stack;
}
}
@Override
public void setStack(int i, IItemStack stack) {
//System.out.println("SetStack(" + i + ") " + stack);
if (stack != stacks[i]) {
if (stack == null) {
stackCount--;
inventory.setInventorySlotContents(i, null);
} else {
inventory.setInventorySlotContents(i, getItemStack(stack));
if (stacks[i] == null) {
stackCount++;
}
}
stacks[i] = stack;
}
}
private boolean changed(int i) {
if (original[i] != inventory.getStackInSlot(i)) return true;
if (original[i] != null && stacks[i].getAmount() != original[i].stackSize) return true;
return false;
}
}
@@ -1,419 +0,0 @@
package minetweaker.mc164.recipes;
import minetweaker.api.recipes.ShapedRecipe;
import minetweaker.api.recipes.ShapelessRecipe;
import java.util.ArrayList;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.mc164.util.MineTweakerHacks;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getOreDict;
import minetweaker.api.player.IPlayer;
import minetweaker.api.recipes.ICraftingInventory;
import minetweaker.api.recipes.ICraftingRecipe;
import minetweaker.api.recipes.IRecipeFunction;
import minetweaker.api.recipes.IRecipeManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
/**
*
* @author Stan
*/
public class MCRecipeManager implements IRecipeManager {
private final List<IRecipe> recipes;
private final List<ICraftingRecipe> transformerRecipes;
public MCRecipeManager() {
recipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList();
transformerRecipes = new ArrayList<ICraftingRecipe>();
}
public boolean hasTransformerRecipes() {
return transformerRecipes.size() > 0;
}
public void applyTransformations(ICraftingInventory inventory, IPlayer player) {
for (ICraftingRecipe recipe : transformerRecipes) {
if (recipe.matches(inventory)) {
recipe.applyTransformers(inventory, player);
return;
}
}
}
@Override
public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient) {
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>();
for (IRecipe recipe : recipes) {
if (ingredient.matches(MineTweakerMC.getIItemStack(recipe.getRecipeOutput()))) {
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
results.add(converted);
}
}
return results;
}
@Override
public List<ICraftingRecipe> getAll() {
List<ICraftingRecipe> results = new ArrayList<ICraftingRecipe>();
for (IRecipe recipe : recipes) {
ICraftingRecipe converted = RecipeConverter.toCraftingRecipe(recipe);
results.add(converted);
}
return results;
}
@Override
public int remove(IIngredient output) {
List<IRecipe> toRemove = new ArrayList<IRecipe>();
List<Integer> removeIndex = new ArrayList<Integer>();
for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
// certain special recipes have no predefined output. ignore those
// since these cannot be removed with MineTweaker scripts
if (recipe.getRecipeOutput() != null) {
if (output.matches(getIItemStack(recipe.getRecipeOutput()))) {
toRemove.add(recipe);
removeIndex.add(i);
}
}
}
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
return toRemove.size();
}
@Override
public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) {
addShaped(output, ingredients, null, false);
}
@Override
public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) {
addShaped(output, ingredients, null, true);
}
@Override
public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function) {
ShapelessRecipe recipe = new ShapelessRecipe(output, ingredients, function);
IRecipe irecipe = RecipeConverter.convert(recipe);
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
}
@Override
public int removeShaped(IIngredient output, IIngredient[][] ingredients) {
int ingredientsWidth = 0;
int ingredientsHeight = 0;
if (ingredients != null) {
ingredientsHeight = ingredients.length;
for (int i = 0; i < ingredients.length; i++) {
ingredientsWidth = Math.max(ingredientsWidth, ingredients[i].length);
}
}
List<IRecipe> toRemove = new ArrayList<IRecipe>();
List<Integer> removeIndex = new ArrayList<Integer>();
outer: for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
if (recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
continue;
}
if (ingredients != null) {
if (recipe instanceof ShapedRecipes) {
ShapedRecipes srecipe = (ShapedRecipes) recipe;
if (ingredientsWidth != srecipe.recipeWidth || ingredientsHeight != srecipe.recipeHeight) {
continue;
}
for (int j = 0; j < ingredientsHeight; j++) {
IIngredient[] row = ingredients[j];
for (int k = 0; k < ingredientsWidth; k++) {
IIngredient ingredient = k > row.length ? null : row[k];
ItemStack recipeIngredient = srecipe.recipeItems[j * srecipe.recipeWidth + k];
if (!matches(recipeIngredient, ingredient)) {
continue outer;
}
}
}
} else if (recipe instanceof ShapedOreRecipe) {
ShapedOreRecipe srecipe = (ShapedOreRecipe) recipe;
int recipeWidth = MineTweakerHacks.getShapedOreRecipeWidth(srecipe);
int recipeHeight = srecipe.getRecipeSize() / recipeWidth;
if (ingredientsWidth != recipeWidth || ingredientsHeight != recipeHeight) {
continue;
}
for (int j = 0; j < ingredientsHeight; j++) {
IIngredient[] row = ingredients[j];
for (int k = 0; k < ingredientsWidth; k++) {
IIngredient ingredient = k > row.length ? null : row[k];
Object input = srecipe.getInput()[j * recipeWidth + k];
if (!matches(input, ingredient)) {
continue outer;
}
}
}
}
} else {
if (recipe instanceof ShapedRecipes) {
} else if (recipe instanceof ShapedOreRecipe) {
} else {
continue;
}
}
toRemove.add(recipe);
removeIndex.add(i);
}
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
return toRemove.size();
}
@Override
public int removeShapeless(IIngredient output, IIngredient[] ingredients, boolean wildcard) {
List<IRecipe> toRemove = new ArrayList<IRecipe>();
List<Integer> removeIndex = new ArrayList<Integer>();
outer: for (int i = 0; i < recipes.size(); i++) {
IRecipe recipe = recipes.get(i);
if (recipe.getRecipeOutput() == null || !output.matches(getIItemStack(recipe.getRecipeOutput()))) {
continue;
}
if (ingredients != null) {
if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes srecipe = (ShapelessRecipes) recipe;
if (ingredients.length > srecipe.getRecipeSize()) {
continue;
} else if (!wildcard && ingredients.length < srecipe.getRecipeSize()) {
continue;
}
checkIngredient: for (int j = 0; j < ingredients.length; j++) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(srecipe.recipeItems.get(k), ingredients[j])) {
continue checkIngredient;
}
}
continue outer;
}
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe srecipe = (ShapelessOreRecipe) recipe;
ArrayList<Object> inputs = srecipe.getInput();
if (inputs.size() < ingredients.length) {
continue;
} if (!wildcard && inputs.size() > ingredients.length) {
continue;
}
checkIngredient: for (int j = 0; j < ingredients.length; j++) {
for (int k = 0; k < srecipe.getRecipeSize(); k++) {
if (matches(inputs.get(k), ingredients[j])) {
continue checkIngredient;
}
}
continue outer;
}
}
} else {
if (recipe instanceof ShapelessRecipes) {
} else if (recipe instanceof ShapelessOreRecipe) {
} else {
continue;
}
}
toRemove.add(recipe);
removeIndex.add(i);
}
MineTweakerAPI.apply(new ActionRemoveRecipes(toRemove, removeIndex));
return toRemove.size();
}
@Override
public IItemStack craft(IItemStack[][] contents) {
Container container = new ContainerVirtual();
int width = 0;
int height = contents.length;
for (IItemStack[] row : contents) {
width = Math.max(width, row.length);
}
ItemStack[] iContents = new ItemStack[width * height];
for (int i = 0; i < height; i++) {
for (int j = 0; j < contents[i].length; j++) {
if (contents[i][j] != null) {
iContents[i * width + j] = getItemStack(contents[j][j]);
}
}
}
InventoryCrafting inventory = new InventoryCrafting(container, width, height);
for (int i = 0; i < iContents.length; i++) {
inventory.setInventorySlotContents(i, iContents[i]);
}
ItemStack result = CraftingManager.getInstance().findMatchingRecipe(inventory, null);
if (result == null) {
return null;
} else {
return getIItemStack(result);
}
}
private class ContainerVirtual extends Container {
@Override
public boolean canInteractWith(EntityPlayer var1) {
return false;
}
}
private class ActionRemoveRecipes implements IUndoableAction {
private final List<Integer> removingIndices;
private final List<IRecipe> removingRecipes;
public ActionRemoveRecipes(List<IRecipe> recipes, List<Integer> indices) {
this.removingIndices = indices;
this.removingRecipes = recipes;
}
@Override
public void apply() {
for (int i = removingIndices.size() - 1; i >= 0; i--) {
recipes.remove((int) removingIndices.get(i));
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
for (int i = 0; i < removingIndices.size(); i++) {
int index = Math.min(recipes.size(), removingIndices.get(i));
recipes.add(index, removingRecipes.get(i));
}
}
@Override
public String describe() {
return "Removing " + removingIndices.size() + " recipes";
}
@Override
public String describeUndo() {
return "Restoring " + removingIndices.size() + " recipes";
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class ActionAddRecipe implements IUndoableAction {
private final IRecipe recipe;
private final ICraftingRecipe craftingRecipe;
public ActionAddRecipe(IRecipe recipe, ICraftingRecipe craftingRecipe) {
this.recipe = recipe;
this.craftingRecipe = craftingRecipe;
}
@Override
public void apply() {
recipes.add(recipe);
if (craftingRecipe.hasTransformers()) {
transformerRecipes.add(craftingRecipe);
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
recipes.remove(recipe);
if (craftingRecipe.hasTransformers()) {
transformerRecipes.remove(craftingRecipe);
}
}
@Override
public String describe() {
return "Adding recipe for " + recipe.getRecipeOutput().getDisplayName();
}
@Override
public String describeUndo() {
return "Removing recipe for " + recipe.getRecipeOutput().getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static boolean matches(Object input, IIngredient ingredient) {
if ((input == null) != (ingredient == null)) {
return false;
} else if (ingredient != null) {
if (input instanceof ItemStack) {
if (!ingredient.matches(getIItemStack((ItemStack) input))) {
return false;
}
} else if (input instanceof String) {
if (!ingredient.contains(getOreDict((String) input))) {
return false;
}
}
}
return true;
}
private void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, boolean mirrored) {
ShapedRecipe recipe = new ShapedRecipe(output, ingredients, function, mirrored);
IRecipe irecipe = RecipeConverter.convert(recipe);
MineTweakerAPI.apply(new ActionAddRecipe(irecipe, recipe));
}
}
@@ -1,186 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import minetweaker.api.recipes.ShapedRecipe;
import minetweaker.api.recipes.ShapelessRecipe;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.recipes.ICraftingRecipe;
import minetweaker.api.recipes.UnknownRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
/**
*
* @author Stan
*/
public class RecipeConverter {
private RecipeConverter() {}
public static final int TYPE_ADVANCED = 0;
public static final int TYPE_ORE = 1;
public static final int TYPE_BASIC = 2;
private static int getIngredientType(IIngredient pattern) {
Object internal = pattern.getInternal();
if (internal == null) {
return TYPE_ADVANCED;
} else if (internal instanceof ItemStack) {
return TYPE_BASIC;
} else {
return TYPE_ORE;
}
}
private static int getRecipeType(IIngredient[] ingredients) {
int type = TYPE_BASIC;
for (IIngredient ingredient : ingredients) {
type = Math.min(type, getIngredientType(ingredient));
}
return type;
}
public static IRecipe convert(ShapelessRecipe recipe) {
IIngredient[] ingredients = recipe.getIngredients();
int type = getRecipeType(ingredients);
if (type == TYPE_BASIC) {
ItemStack[] items = new ItemStack[ingredients.length];
for (int i = 0; i < ingredients.length; i++) {
items[i] = getItemStack(ingredients[i]);
}
return new ShapelessRecipeBasic(items, recipe);
} else if (type == TYPE_ORE) {
Object[] items = new Object[ingredients.length];
for (int i = 0; i < ingredients.length; i++) {
items[i] = ingredients[i].getInternal();
}
return new ShapelessRecipeOre(items, recipe);
} else {
return new ShapelessRecipeAdvanced(recipe);
}
}
public static IRecipe convert(ShapedRecipe recipe) {
IIngredient[] ingredients = recipe.getIngredients();
byte[] posx = recipe.getIngredientsX();
byte[] posy = recipe.getIngredientsY();
// determine recipe type
int type = getRecipeType(ingredients);
// construct recipe
if (type == TYPE_BASIC) {
System.out.println("Converted to basic recipe");
ItemStack[] basicIngredients = new ItemStack[recipe.getHeight() * recipe.getWidth()];
for (int i = 0; i < ingredients.length; i++) {
basicIngredients[posx[i] + posy[i] * recipe.getWidth()] = getItemStack(ingredients[i]);
}
return new ShapedRecipeBasic(basicIngredients, recipe);
} else if (type == TYPE_ORE) {
System.out.println("Converted to ore recipe");
Object[] converted = new Object[recipe.getHeight() * recipe.getWidth()];
for (int i = 0; i < ingredients.length; i++) {
converted[posx[i] + posy[i] * recipe.getWidth()] = ingredients[i].getInternal();
}
// arguments contents:
// 1) recipe patterns
// 2) characters + ingredients
int counter = 0;
String[] parts = new String[recipe.getHeight()];
ArrayList rarguments = new ArrayList();
for (int i = 0; i < recipe.getHeight(); i++) {
char[] pattern = new char[recipe.getWidth()];
for (int j = 0; j < recipe.getWidth(); j++) {
int off = i * recipe.getWidth() + j;
if (converted[off] == null) {
pattern[j] = ' ';
} else {
pattern[j] = (char) ('A' + counter);
rarguments.add(pattern[j]);
rarguments.add(converted[off]);
counter++;
}
}
parts[i] = new String(pattern);
}
rarguments.addAll(0, Arrays.asList(parts));
return new ShapedRecipeOre(rarguments.toArray(), recipe);
} else {
System.out.println("Converted to advanced recipe");
return new ShapedRecipeAdvanced(recipe);
}
}
public static ICraftingRecipe toCraftingRecipe(IRecipe recipe) {
IItemStack output = MineTweakerMC.getIItemStack(recipe.getRecipeOutput());
if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
IIngredient[] ingredients = new IIngredient[shapeless.recipeItems.size()];
for (int i = 0; i < ingredients.length; i++) {
ingredients[i] = MineTweakerMC.getIIngredient(shapeless.recipeItems.get(i));
}
return new ShapelessRecipe(output, ingredients, null);
} else if (recipe instanceof ShapedRecipes) {
ShapedRecipes shaped = (ShapedRecipes) recipe;
IIngredient[][] ingredients = new IIngredient[shaped.recipeHeight][shaped.recipeWidth];
for (int i = 0; i < shaped.recipeHeight; i++) {
for (int j = 0; j < shaped.recipeWidth; j++) {
ingredients[i][j] = MineTweakerMC.getIItemStack(shaped.recipeItems[i * shaped.recipeWidth + j]);
}
}
return new ShapedRecipe(output, ingredients, null, false);
} else if (recipe instanceof ShapedOreRecipe) {
ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
int width = (int) Math.sqrt(recipe.getRecipeSize());
int height = recipe.getRecipeSize() / width;
IIngredient[][] recipeIngredients = new IIngredient[height][width];
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
recipeIngredients[i][j] = MineTweakerMC.getIIngredient(shaped.getInput()[i * width + j]);
}
}
return new ShapedRecipe(output, recipeIngredients, null, false);
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
IIngredient[] ingredients = new IIngredient[shapeless.getRecipeSize()];
for (int i = 0; i < ingredients.length; i++) {
ingredients[i] = MineTweakerMC.getIIngredient(shapeless.getInput().get(i));
}
return new ShapelessRecipe(output, ingredients, null);
} else {
return new UnknownRecipe(output);
}
}
}
@@ -1,47 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.recipes.ShapedRecipe;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
/**
* TODO: NEI integration for this kind of recipes.
*
* @author Stan
*/
public class ShapedRecipeAdvanced implements IRecipe {
private final ShapedRecipe recipe;
public ShapedRecipeAdvanced(ShapedRecipe recipe) {
this.recipe = recipe;
}
@Override
public boolean matches(InventoryCrafting inventory, World world) {
return recipe.matches(MCCraftingInventory.get(inventory));
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
}
@Override
public int getRecipeSize() {
return recipe.getWidth() * recipe.getHeight();
}
@Override
public ItemStack getRecipeOutput() {
return getItemStack(recipe.getOutput());
}
}
@@ -1,44 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import minetweaker.api.item.IItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.recipes.ShapedRecipe;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.world.World;
/**
*
* @author Stan
*/
public class ShapedRecipeBasic extends ShapedRecipes {
private final ShapedRecipe recipe;
public ShapedRecipeBasic(ItemStack[] basicInputs, ShapedRecipe recipe) {
super(recipe.getWidth(), recipe.getHeight(), basicInputs, getItemStack(recipe.getOutput()));
this.recipe = recipe;
}
@Override
public boolean matches(InventoryCrafting inventory, World world) {
return recipe.matches(MCCraftingInventory.get(inventory));
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
IItemStack result = recipe.getCraftingResult(MCCraftingInventory.get(inventory));
if (result == null) {
return null;
} else {
return getItemStack(result).copy();
}
}
}
@@ -1,38 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.recipes.ShapedRecipe;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapedOreRecipe;
/**
*
* @author Stan
*/
public class ShapedRecipeOre extends ShapedOreRecipe {
private final ShapedRecipe recipe;
public ShapedRecipeOre(Object[] contents, ShapedRecipe recipe) {
super(getItemStack(recipe.getOutput()), contents);
this.recipe = recipe;
}
@Override
public boolean matches(InventoryCrafting inventory, World world) {
return recipe.matches(MCCraftingInventory.get(inventory));
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
}
}
@@ -1,46 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.recipes.ShapelessRecipe;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
/**
*
* @author Stan
*/
public class ShapelessRecipeAdvanced implements IRecipe {
private final ShapelessRecipe recipe;
public ShapelessRecipeAdvanced(ShapelessRecipe recipe) {
this.recipe = recipe;
}
@Override
public boolean matches(InventoryCrafting inventory, World world) {
return recipe.matches(MCCraftingInventory.get(inventory));
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
}
@Override
public int getRecipeSize() {
return recipe.getSize();
}
@Override
public ItemStack getRecipeOutput() {
return getItemStack(recipe.getOutput());
}
}
@@ -1,39 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import minetweaker.api.recipes.ShapelessRecipe;
import java.util.Arrays;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
/**
*
* @author Stan
*/
public class ShapelessRecipeBasic extends ShapelessRecipes {
private final ShapelessRecipe recipe;
public ShapelessRecipeBasic(ItemStack[] ingredients, ShapelessRecipe recipe) {
super(getItemStack(recipe.getOutput()), Arrays.asList(ingredients));
this.recipe = recipe;
}
@Override
public boolean matches(InventoryCrafting inventory, World world) {
return recipe.matches(MCCraftingInventory.get(inventory));
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
}
}
@@ -1,38 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.recipes;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.recipes.ShapelessRecipe;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapelessOreRecipe;
/**
*
* @author Stan
*/
public class ShapelessRecipeOre extends ShapelessOreRecipe {
private final ShapelessRecipe recipe;
public ShapelessRecipeOre(Object[] ingredients, ShapelessRecipe recipe) {
super(getItemStack(recipe.getOutput()), ingredients);
this.recipe = recipe;
}
@Override
public boolean matches(InventoryCrafting inventory, World world) {
return recipe.matches(MCCraftingInventory.get(inventory));
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
}
}
@@ -1,226 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.server;
import java.util.Arrays;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.AbstractServer;
import minetweaker.api.server.ICommandFunction;
import minetweaker.api.server.ICommandTabCompletion;
import minetweaker.api.server.ICommandValidator;
import net.minecraft.command.CommandHandler;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
/**
*
* @author Stan
*/
public class MCServer extends AbstractServer {
private final MinecraftServer server;
public MCServer(MinecraftServer server) {
this.server = server;
}
@Override
public void addCommand(String name, String usage, String[] aliases, ICommandFunction function, ICommandValidator validator, ICommandTabCompletion completion) {
ICommand command = new MCCommand(name, usage, aliases, function, validator, completion);
MineTweakerAPI.apply(new AddCommandAction(command));
}
@Override
public void removeCommand(String name) {
ICommand command = (ICommand)((CommandHandler) server.getCommandManager()).getCommands().get(name);
if (command == null) {
MineTweakerAPI.logWarning("No such command: " + name);
} else {
MineTweakerAPI.apply(new RemoveCommandAction(command));
}
}
@Override
public boolean isOp(IPlayer player) {
return MinecraftServer.getServer().getConfigurationManager().getOps().isEmpty()
|| MinecraftServer.getServer().getConfigurationManager().getOps().contains(player.getName())
|| player == ServerPlayer.INSTANCE;
}
private static IPlayer getPlayer(ICommandSender commandSender) {
if (commandSender instanceof EntityPlayer) {
return MineTweakerMC.getIPlayer((EntityPlayer) commandSender);
} else if (commandSender instanceof DedicatedServer) {
return ServerPlayer.INSTANCE;
} else {
System.out.println("Unsupported command sender: " + commandSender);
System.out.println("player name: " + commandSender.getCommandSenderName());
return null;
}
}
private static void removeCommand(ICommand command) {
CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager();
ch.getCommands().remove(command.getCommandName());
if (command.getCommandAliases() != null) {
for (String alias : (List<String>)command.getCommandAliases()) {
ch.getCommands().remove(alias);
}
}
}
private class MCCommand implements ICommand {
private final String name;
private final String usage;
private final List<String> aliases;
private final ICommandFunction function;
private final ICommandValidator validator;
private final ICommandTabCompletion completion;
public MCCommand(String name, String usage, String[] aliases, ICommandFunction function, ICommandValidator validator, ICommandTabCompletion completion) {
this.name = name;
this.usage = usage;
this.aliases = Arrays.asList(aliases);
this.function = function;
this.validator = validator;
this.completion = completion;
}
@Override
public String getCommandName() {
return name;
}
@Override
public String getCommandUsage(ICommandSender var1) {
return usage;
}
@Override
public List getCommandAliases() {
return aliases;
}
@Override
public void processCommand(ICommandSender var1, String[] var2) {
function.execute(var2, getPlayer(var1));
}
@Override
public boolean canCommandSenderUseCommand(ICommandSender var1) {
if (validator == null) {
return true;
} else {
return validator.canExecute(getPlayer(var1));
}
}
@Override
public List addTabCompletionOptions(ICommandSender var1, String[] var2) {
if (completion != null) {
return Arrays.asList(completion.getTabCompletionOptions(var2, getPlayer(var1)));
} else {
return null;
}
}
@Override
public boolean isUsernameIndex(String[] var1, int var2) {
return false;
}
@Override
public int compareTo(Object o) {
return 0;
}
}
private class AddCommandAction implements IUndoableAction {
private final ICommand command;
public AddCommandAction(ICommand command) {
this.command = command;
}
@Override
public void apply() {
CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager();
ch.registerCommand(command);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
removeCommand(command);
}
@Override
public String describe() {
return "Adding command " + command.getCommandName();
}
@Override
public String describeUndo() {
return "Removing command " + command.getCommandName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
private class RemoveCommandAction implements IUndoableAction {
private final ICommand command;
public RemoveCommandAction(ICommand command) {
this.command = command;
}
@Override
public void apply() {
removeCommand(command);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager();
ch.registerCommand(command);
}
@Override
public String describe() {
return "Adding command " + command.getCommandName();
}
@Override
public String describeUndo() {
return "Removing command " + command.getCommandName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,125 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.server;
import java.awt.Desktop;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
import minetweaker.api.chat.IChatMessage;
import minetweaker.api.data.IData;
import minetweaker.api.item.IItemStack;
import minetweaker.api.player.IPlayer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.util.ChatMessageComponent;
/**
*
* @author Stan
*/
public class ServerPlayer implements IPlayer {
public static final ServerPlayer INSTANCE = new ServerPlayer();
private ServerPlayer() {
}
@Override
public String getId() {
return "server";
}
@Override
public String getName() {
return "Server";
}
@Override
public IData getData() {
// TODO: implement
return null;
}
@Override
public void update(IData data) {
// TODO: implement
}
@Override
public void sendChat(IChatMessage message) {
DedicatedServer.getServer().sendChatToPlayer((ChatMessageComponent) message.getInternal());
}
@Override
public void sendChat(String message) {
DedicatedServer.getServer().sendChatToPlayer(ChatMessageComponent.createFromText(message));
}
@Override
public int getHotbarSize() {
return 0;
}
@Override
public IItemStack getHotbarStack(int i) {
return null;
}
@Override
public int getInventorySize() {
return 0;
}
@Override
public IItemStack getInventoryStack(int i) {
return null;
}
@Override
public IItemStack getCurrentItem() {
return null;
}
@Override
public boolean isCreative() {
return true;
}
@Override
public boolean isAdventure() {
return false;
}
@Override
public void openBrowser(String url) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(URI.create(url));
} catch (IOException ex) {
Logger.getLogger(ServerPlayer.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@Override
public void copyToClipboard(String value) {
if (Desktop.isDesktopSupported()) {
StringSelection stringSelection = new StringSelection(value);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
}
@Override
public void give(IItemStack stack) {
}
}
@@ -1,306 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.util;
import com.google.common.collect.BiMap;
import cpw.mods.fml.common.registry.EntityRegistry;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.WeightedItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.SlotCrafting;import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StatCollector;
import net.minecraft.util.StringTranslate;
import net.minecraft.util.WeightedRandomItem;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
/**
* Common class for all runtime hacks (stuff requiring reflection). It is not
* unexpected to have it break with new minecraft versions and may need regular
* adjustment - as such, those have been collected here.
*
* @author Stan Hebben
*/
public class MineTweakerHacks {
private static final Field NBTTAGCOMPOUND_TAGMAP;
private static final Field OREDICTIONARY_ORESTACKS;
private static final Field MINECRAFTSERVER_ANVILFILE;
private static final Field SHAPEDORERECIPE_WIDTH;
private static final Field INVENTORYCRAFTING_EVENTHANDLER;
private static final Field SLOTCRAFTING_PLAYER;
private static final Field ENTITYREGISTRY_CLASSREGISTRATIONS;
private static final Field SEEDENTRY_SEED;
private static final Constructor<? extends WeightedRandomItem> SEEDENTRY_CONSTRUCTOR;
static {
NBTTAGCOMPOUND_TAGMAP = getField(NBTTagCompound.class, MineTweakerObfuscation.NBTTAGCOMPOUND_TAGMAP);
OREDICTIONARY_ORESTACKS = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_ORESTACKS);
MINECRAFTSERVER_ANVILFILE = getField(MinecraftServer.class, MineTweakerObfuscation.MINECRAFTSERVER_ANVILFILE);
SHAPEDORERECIPE_WIDTH = getField(ShapedOreRecipe.class, new String[] {"width"});
INVENTORYCRAFTING_EVENTHANDLER = getField(InventoryCrafting.class, MineTweakerObfuscation.INVENTORYCRAFTING_EVENTHANDLER);
SLOTCRAFTING_PLAYER = getField(SlotCrafting.class, MineTweakerObfuscation.SLOTCRAFTING_PLAYER);
ENTITYREGISTRY_CLASSREGISTRATIONS = getField(EntityRegistry.class, new String[] {"entityClassRegistrations"});
Class<? extends WeightedRandomItem> forgeSeedEntry = null;
try {
forgeSeedEntry = (Class<? extends WeightedRandomItem>) Class.forName("net.minecraftforge.common.ForgeHooks$SeedEntry");
} catch (ClassNotFoundException ex) {}
SEEDENTRY_SEED = getField(forgeSeedEntry, "seed");
Constructor<? extends WeightedRandomItem> seedEntryConstructor = null;
try {
seedEntryConstructor = forgeSeedEntry.getConstructor(ItemStack.class, int.class);
seedEntryConstructor.setAccessible(true);
} catch (NoSuchMethodException ex) {
Logger.getLogger(MineTweakerHacks.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(MineTweakerHacks.class.getName()).log(Level.SEVERE, null, ex);
}
SEEDENTRY_CONSTRUCTOR = seedEntryConstructor;
}
private MineTweakerHacks() {}
public static BiMap<Class<? extends Entity>, EntityRegistry.EntityRegistration> getEntityClassRegistrations() {
try {
return (BiMap<Class<? extends Entity>, EntityRegistry.EntityRegistration>) ENTITYREGISTRY_CLASSREGISTRATIONS.get(EntityRegistry.instance());
} catch (IllegalArgumentException ex) {
return null;
} catch (IllegalAccessException ex) {
return null;
}
}
public static Map<String, NBTBase> getNBTCompoundMap(NBTTagCompound tag) {
try {
return (Map<String, NBTBase>) NBTTAGCOMPOUND_TAGMAP.get(tag);
} catch (IllegalArgumentException ex) {
return null;
} catch (IllegalAccessException ex) {
return null;
}
}
public static List getSeeds() {
return getPrivateStaticObject(ForgeHooks.class, "seedList");
}
public static Map<String, ChestGenHooks> getChestLoot() {
return getPrivateStaticObject(ChestGenHooks.class, "chestInfo");
}
public static Map getTranslations() {
return getPrivateObject(
getPrivateStaticObject(StatCollector.class, "localizedName", "field_74839_a"),
"languageList",
"field_74816_c");
}
public static Map<Integer, List<ItemStack>> getOreStacks() {
try {
return (Map<Integer, List<ItemStack>>) OREDICTIONARY_ORESTACKS.get(null);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("ERROR - could not load ore dictionary stacks!");
return null;
}
}
public static File getAnvilFile(MinecraftServer server) {
try {
return (File) MINECRAFTSERVER_ANVILFILE.get(server);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not load anvil file!");
return null;
}
}
public static File getWorldDirectory(MinecraftServer server) {
if (server.isDedicatedServer()) {
return server.getFile("world");
} else {
File worldsDir = getAnvilFile(server);
if (worldsDir == null) return null;
return new File(worldsDir, server.getFolderName());
}
}
public static int getShapedOreRecipeWidth(ShapedOreRecipe recipe) {
try {
return SHAPEDORERECIPE_WIDTH.getInt(recipe);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not load anvil file!");
return 3;
}
}
public static Container getCraftingContainer(InventoryCrafting inventory) {
try {
return (Container) INVENTORYCRAFTING_EVENTHANDLER.get(inventory);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not get inventory eventhandler");
return null;
}
}
public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) {
try {
return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not get inventory eventhandler");
return null;
}
}
public static StringTranslate getStringTranslateInstance() {
try {
Field field = getField(StringTranslate.class, MineTweakerObfuscation.STRINGTRANSLATE_INSTANCE);
return (StringTranslate) field.get(null);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not get string translator");
return null;
}
}
public static Map<List, FluidContainerData> getFluidContainerMap() {
try {
Field field = getField(FluidContainerRegistry.class, new String[] {"containerFluidMap"});
return (Map<List, FluidContainerData>) field.get(null);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not get fluid container registry");
return null;
}
}
public static Map<List, FluidContainerData> getFilledContainerMap() {
try {
Field field = getField(FluidContainerRegistry.class, new String[] {"filledContainerMap"});
return (Map<List, FluidContainerData>) field.get(null);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not get filled container map");
return null;
}
}
public static Set<List> getEmptyContainers() {
try {
Field field = getField(FluidContainerRegistry.class, new String[] {"emptyContainers"});
return (Set<List>) field.get(null);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not get filled container map");
return null;
}
}
public static ItemStack getSeedEntrySeed(Object entry) {
try {
return (ItemStack) SEEDENTRY_SEED.get(entry);
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not get SeedEntry seed");
return null;
}
}
public static WeightedRandomItem constructSeedEntry(WeightedItemStack stack) {
try {
return SEEDENTRY_CONSTRUCTOR.newInstance(MineTweakerMC.getItemStack(stack.getStack()), (int) stack.getChance());
} catch (InstantiationException ex) {
MineTweakerAPI.logError("could not construct SeedEntry");
} catch (IllegalAccessException ex) {
MineTweakerAPI.logError("could not construct SeedEntry");
} catch (IllegalArgumentException ex) {
MineTweakerAPI.logError("could not construct SeedEntry");
} catch (InvocationTargetException ex) {
MineTweakerAPI.logError("could not construct SeedEntry");
}
return null;
}
public static <T> T getPrivateStaticObject(Class<?> cls, String... names) {
for (String name : names) {
try {
Field field = cls.getDeclaredField(name);
field.setAccessible(true);
return (T) field.get(null);
} catch (NoSuchFieldException ex) {
} catch (SecurityException ex) {
} catch (IllegalAccessException ex) {
}
}
return null;
}
public static <T> T getPrivateObject(Object object, String... names) {
Class<?> cls = object.getClass();
for (String name : names) {
try {
Field field = cls.getDeclaredField(name);
field.setAccessible(true);
return (T) field.get(object);
} catch (NoSuchFieldException ex) {
} catch (SecurityException ex) {
} catch (IllegalAccessException ex) {
}
}
return null;
}
// #######################
// ### Private Methods ###
// #######################
private static Field getField(Class cls, String... names) {
for (String name : names) {
try {
Field field = cls.getDeclaredField(name);
field.setAccessible(true);
return field;
} catch (NoSuchFieldException ex) {
} catch (SecurityException ex) {
}
}
return null;
}
}
@@ -1,22 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.util;
/**
*
* @author Stanneke
*/
public class MineTweakerObfuscation {
private MineTweakerObfuscation() {}
public static final String[] NBTTAGCOMPOUND_TAGMAP = {"tagMap", "field_74784_a"};
public static final String[] OREDICTIONARY_ORESTACKS = {"oreStacks"};
public static final String[] MINECRAFTSERVER_ANVILFILE = {"anvilFile", "field_71308_o"};
public static final String[] INVENTORYCRAFTING_EVENTHANDLER = {"eventHandler", "field_70465_c"};
public static final String[] SLOTCRAFTING_PLAYER = {"thePlayer", "field_75238_b"};
public static final String[] STRINGTRANSLATE_INSTANCE = {"instance", "field_74817_a"};
}
@@ -1,45 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.util;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.EntityLivingBase;
/**
*
* @author Stan
*/
public class MineTweakerPlatformUtils {
private MineTweakerPlatformUtils() {}
public static Class<? extends EntityLivingBase> getLivingEntityClass(String entityClassName) {
try {
Class<?> entityClass = Class.forName(entityClassName);
if (!EntityLivingBase.class.isAssignableFrom(entityClass)) {
throw new RuntimeException("Not an entity class: " + entityClassName);
}
return (Class<? extends EntityLivingBase>) entityClass;
} catch (ClassNotFoundException ex) {
throw new RuntimeException("entity class not found: " + entityClassName);
}
}
public static String getLanguage() {
return FMLCommonHandler.instance().getSide() == Side.SERVER ? null : FMLClientHandler.instance().getCurrentLanguage();
}
public static boolean isLanguageActive(String lang) {
String current = getLanguage();
return current != null && current.equals(lang);
}
public static boolean isClient() {
return FMLCommonHandler.instance().getSide() == Side.CLIENT;
}
}
@@ -1,203 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.vanilla;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.WeightedItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.vanilla.ILootRegistry;
import minetweaker.api.vanilla.LootEntry;
import minetweaker.mc164.util.MineTweakerHacks;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
/**
*
* @author Stan
*/
public class MCLootRegistry implements ILootRegistry {
private static final Map<String, ChestGenHooks> LOOT = MineTweakerHacks.getChestLoot();
@Override
public void addChestLoot(String type, WeightedItemStack item) {
WeightedRandomChestContent content = new WeightedRandomChestContent(
MineTweakerMC.getItemStack(item.getStack()),
1,
1,
(int) item.getChance());
MineTweakerAPI.apply(new AddLootAction(type, content));
}
@Override
public void addChestLoot(String type, WeightedItemStack item, int min, int max) {
WeightedRandomChestContent content = new WeightedRandomChestContent(
MineTweakerMC.getItemStack(item.getStack()),
min,
max,
(int) item.getChance());
MineTweakerAPI.apply(new AddLootAction(type, content));
}
@Override
public void removeChestLoot(String type, IIngredient pattern) {
MineTweakerAPI.apply(new RemoveLootAction(type, pattern));
}
@Override
public List<LootEntry> getLoot(String type) {
ChestGenHooks recipe = LOOT.get(type);
List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
List<LootEntry> results = new ArrayList<LootEntry>();
for (WeightedRandomChestContent content : contents) {
results.add(new LootEntry(new WeightedItemStack(
MineTweakerMC.getIItemStack(content.theItemId),
content.itemWeight),
content.theMinimumChanceToGenerateItem,
content.theMaximumChanceToGenerateItem));
}
return results;
}
@Override
public List<String> getLootTypes() {
Set<String> keys = LOOT.keySet();
List<String> keyList = new ArrayList<String>();
keyList.addAll(keys);
return keyList;
}
// ######################
// ### Action Classes ###
// ######################
/**
* Ported from ModTweaker.
*
* @author JoshieJack
*/
private static class AddLootAction implements IUndoableAction {
private final String chest;
private final WeightedRandomChestContent content;
public AddLootAction(String chest, WeightedRandomChestContent content) {
this.chest = chest;
this.content = content;
}
@Override
public void apply() {
ChestGenHooks recipe = LOOT.get(chest);
List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
contents.add(content);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
ChestGenHooks recipe = LOOT.get(chest);
List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
contents.remove(content);
}
public String getRecipeInfo() {
return content.theItemId.getDisplayName();
}
@Override
public String describe() {
return "Adding chest loot " + content.theItemId.getDisplayName() + " to loot class " + chest;
}
@Override
public String describeUndo() {
return "Removing chest loot " + content.theItemId.getDisplayName() + " from loot class " + chest;
}
@Override
public Object getOverrideKey() {
return null;
}
}
/**
* Ported from ModTweaker.
*
* @author JoshieJack
*/
private static class RemoveLootAction implements IUndoableAction {
private final String chest;
private final IIngredient pattern;
private final List<WeightedRandomChestContent> removed;
public RemoveLootAction(String chest, IIngredient pattern) {
this.chest = chest;
this.pattern = pattern;
removed = new ArrayList<WeightedRandomChestContent>();
}
@Override
public void apply() {
removed.clear();
ChestGenHooks recipe = LOOT.get(chest);
List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
for (WeightedRandomChestContent r : contents) {
if (pattern.matches(MineTweakerMC.getIItemStack(r.theItemId))) {
removed.add(r);
}
}
for (WeightedRandomChestContent r : removed) {
contents.remove(r);
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
ChestGenHooks recipe = LOOT.get(chest);
List<WeightedRandomChestContent> contents = MineTweakerHacks.getPrivateObject(recipe, "contents");
for (WeightedRandomChestContent entry : removed) {
contents.add(entry);
}
}
@Override
public String describe() {
return "Removing chest loot " + pattern + " for loot type " + chest;
}
@Override
public String describeUndo() {
return "Restoring chest loot " + pattern + " for loot type " + chest + " (" + removed.size() + " entries)";
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,150 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.vanilla;
import java.util.ArrayList;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.WeightedItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.vanilla.ISeedRegistry;
import minetweaker.mc164.util.MineTweakerHacks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.WeightedRandomItem;
/**
*
* @author Stan
*/
public class MCSeedRegistry implements ISeedRegistry {
private static final List SEEDS = MineTweakerHacks.getSeeds();
@Override
public void addSeed(WeightedItemStack item) {
MineTweakerAPI.apply(new AddSeedAction(item));
}
@Override
public void removeSeed(IIngredient pattern) {
MineTweakerAPI.apply(new RemoveSeedAction(pattern));
}
@Override
public List<WeightedItemStack> getSeeds() {
List<? extends WeightedRandomItem> entries = (List<? extends WeightedRandomItem>) SEEDS;
List<WeightedItemStack> results = new ArrayList<WeightedItemStack>();
for (WeightedRandomItem entry : entries) {
results.add(new WeightedItemStack(
MineTweakerMC.getIItemStack(MineTweakerHacks.getSeedEntrySeed(entry)),
entry.itemWeight
));
}
return results;
}
// ######################
// ### Action classes ###
// ######################
private static class AddSeedAction implements IUndoableAction {
private final IItemStack item;
private final WeightedRandomItem entry;
public AddSeedAction(WeightedItemStack item) {
this.item = item.getStack();
entry = MineTweakerHacks.constructSeedEntry(item);
}
@Override
public void apply() {
SEEDS.add(entry);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
SEEDS.remove(entry);
}
@Override
public String describe() {
return "Adding seed entry " + item;
}
@Override
public String describeUndo() {
return "Removing seed entry " + item;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class RemoveSeedAction implements IUndoableAction {
private final IIngredient pattern;
private final List<Object> removed;
public RemoveSeedAction(IIngredient ingredient) {
this.pattern = ingredient;
removed = new ArrayList<Object>();
}
@Override
public void apply() {
removed.clear();
for (Object entry : SEEDS) {
ItemStack itemStack = MineTweakerHacks.getSeedEntrySeed(entry);
if (pattern.matches(MineTweakerMC.getIItemStack(itemStack))) {
removed.add(entry);
}
}
for (Object entry : removed) {
SEEDS.remove(entry);
}
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
for (Object entry : removed) {
SEEDS.add(entry);
}
}
@Override
public String describe() {
return "Removing seeds " + pattern;
}
@Override
public String describeUndo() {
return "Restoring seeds " + pattern + " (" + removed.size() + " entries)";
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,30 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.vanilla;
import minetweaker.api.vanilla.ILootRegistry;
import minetweaker.api.vanilla.ISeedRegistry;
import minetweaker.api.vanilla.IVanilla;
/**
*
* @author Stan
*/
public class MCVanilla implements IVanilla {
private final MCLootRegistry lootRegistry = new MCLootRegistry();
private final MCSeedRegistry seedRegistry = new MCSeedRegistry();
@Override
public ILootRegistry getLoot() {
return lootRegistry;
}
@Override
public ISeedRegistry getSeeds() {
return seedRegistry;
}
}
@@ -1,27 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.world;
import minetweaker.api.world.IBiome;
import net.minecraft.world.biome.BiomeGenBase;
/**
*
* @author Stan
*/
public class MCBiome implements IBiome {
private final BiomeGenBase biome;
public MCBiome(BiomeGenBase biome) {
this.biome = biome;
}
@Override
public String getName() {
return biome.biomeName;
}
}
@@ -1,44 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mc164.world;
import minetweaker.api.block.IBlock;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.world.IDimension;
import net.minecraft.world.World;
/**
*
* @author Stan
*/
public class MCDimension implements IDimension {
private final World world;
public MCDimension(World world) {
this.world = world;
}
@Override
public boolean isDay() {
return world.isDaytime();
}
@Override
public int getBrightness(int x, int y, int z) {
return world.getBlockLightValue(x, y, z);
}
@Override
public IDimension getDimension() {
return this;
}
@Override
public IBlock getBlock(int x, int y, int z) {
return MineTweakerMC.getBlock(world, x, y, z);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

@@ -1,16 +0,0 @@
[
{
"modid": "MineTweaker3",
"name": "MineTweaker 3",
"version": "${version}",
"mcversion": "${mcversion}",
"description": "Customize your minecraft experience!",
"credits": "Created By Stan Hebben",
"logoFile": "assets/minetweaker/logo.png",
"url": "http://minetweaker3.powerofbytes.com",
"authorList": [ "Stan Hebben" ],
"parent": "",
"screenshots": [],
"dependencies": []
}
]
@@ -1,42 +0,0 @@
import minetweaker.tasks.RegisterZenClassesTask;
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'forge'
minecraft {
version = forgeVersion164
}
version = "1.0"
archivesBaseName = project.projectDir.name
dependencies {
compile project(':ZenScript')
compile project(':MineTweaker3-API')
compile project(':MineTweaker3-MC164-Main')
compile files('libs/buildcraft-A-1.6.4-4.2.1.jar')
}
task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main')
outputDir = file('build/classes/main')
className = 'minetweaker.mods.buildcraft.ClassRegistry'
}
tasks.jar.dependsOn(makeRegistry)
@@ -1,182 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mods.buildcraft;
import buildcraft.api.recipes.AssemblyRecipe;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
*
* @author Stan
*/
@ZenClass("mods.buildcraft.AssemblyTable")
@ModOnly("BuildCraft|Core")
public class AssemblyTable {
@ZenMethod
public static void addRecipe(IItemStack output, double energy, IIngredient[] ingredients) {
MineTweakerAPI.apply(new AddRecipeAction(output, energy, ingredients));
}
@ZenMethod
public static void remove(IIngredient output) {
removeRecipe(output, null, false);
}
@ZenMethod
public static void removeRecipe(IIngredient output, @Optional IIngredient[] ingredients, @Optional boolean wildcard) {
List<AssemblyRecipe> toRemove = new ArrayList<AssemblyRecipe>();
outer: for (AssemblyRecipe recipe : AssemblyRecipe.assemblyRecipes) {
if (output.matches(MineTweakerMC.getIItemStack(recipe.output))
&& ingredientsMatch(recipe, ingredients, wildcard)) {
toRemove.add(recipe);
}
}
for (AssemblyRecipe recipe : toRemove) {
MineTweakerAPI.apply(new RemoveRecipeAction(recipe));
}
}
/**
* Checks if ingredients from the recipe match with the given ingredients.
*
* @param recipe recipe to check
* @param ingredients required ingredients
* @param wildcard true if there can be more ingredients in the recipe than given, false otherwise
* @return matching result
*/
private static boolean ingredientsMatch(AssemblyRecipe recipe, IIngredient[] ingredients, boolean wildcard) {
if (ingredients == null)
return true;
int matchedIngredients = 0;
boolean[] matched = new boolean[ingredients.length];
checkIngredient: for (int i = 0; i < recipe.input.length; i++) {
Object ingredientObject = recipe.input[i];
if (ingredientObject instanceof Number)
continue;
IIngredient recipeIngredient = MineTweakerMC.getIIngredient(recipe.input[i]);
for (int j = 0; j < ingredients.length; j++) {
if (!matched[j] && ingredients[j].contains(recipeIngredient)) {
matched[j] = true;
matchedIngredients++;
continue checkIngredient;
}
}
if (!wildcard)
return false;
}
return matchedIngredients == ingredients.length;
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction implements IUndoableAction {
private final IItemStack output;
private final AssemblyRecipe recipe;
public AddRecipeAction(IItemStack output, double energy, IIngredient[] ingredients) {
this.output = output;
Object[] mcIngredients = new Object[ingredients.length];
for (int i = 0; i < ingredients.length; i++) {
mcIngredients[i] = ingredients[i].getInternal();
if (mcIngredients[i] == null) {
throw new IllegalArgumentException("Not a valid assembly table ingredient");
}
}
recipe = new AssemblyRecipe((int) energy, MineTweakerMC.getItemStack(output), mcIngredients);
}
@Override
public void apply() {
AssemblyRecipe.assemblyRecipes.add(recipe);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
AssemblyRecipe.assemblyRecipes.remove(recipe);
}
@Override
public String describe() {
return "Adding assembly table recipe for " + output;
}
@Override
public String describeUndo() {
return "Removing assembly table recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class RemoveRecipeAction implements IUndoableAction {
private final AssemblyRecipe recipe;
public RemoveRecipeAction(AssemblyRecipe recipe) {
this.recipe = recipe;
}
@Override
public void apply() {
AssemblyRecipe.assemblyRecipes.remove(recipe);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
AssemblyRecipe.assemblyRecipes.add(recipe);
}
@Override
public String describe() {
return "Removing assembly table recipe for " + MineTweakerMC.getIItemStack(recipe.output);
}
@Override
public String describeUndo() {
return "Restoring assembly table recipe for " + MineTweakerMC.getIItemStack(recipe.output);
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,375 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mods.buildcraft;
import buildcraft.api.core.StackWrapper;
import buildcraft.api.fuels.IronEngineCoolant;
import buildcraft.api.fuels.IronEngineFuel;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
*
* @author Stan
*/
@ZenClass("mods.buildcraft.Fuels")
@ModOnly("BuildCraft|Core")
public class Fuels {
private static final Constructor CONSTRUCT_FUEL;
static {
Constructor newFuel = null;
try {
newFuel = IronEngineFuel.Fuel.class.getDeclaredConstructor(Fluid.class, float.class, int.class);
newFuel.setAccessible(true);
} catch (NoSuchMethodException ex) {
MineTweakerAPI.logError("Could not load combustion engine fuel constructor", ex);
} catch (SecurityException ex) {
MineTweakerAPI.logError("Could not load combustion engine fuel constructor", ex);
}
CONSTRUCT_FUEL = newFuel;
}
@ZenMethod
public static void addCombustionEngineFuel(ILiquidStack fuel, double powerPerCycle, int totalBurningTime) {
MineTweakerAPI.apply(new AddFuelAction(fuel, powerPerCycle, totalBurningTime));
}
@ZenMethod
public static void removeCombustionEngineFuel(ILiquidStack fuel) {
Fluid fluid = MineTweakerMC.getLiquidStack(fuel).getFluid();
if (IronEngineFuel.fuels.containsKey(fluid.getName())) {
MineTweakerAPI.apply(new RemoveFuelAction(fluid.getName(), IronEngineFuel.fuels.get(fluid.getName())));
} else {
MineTweakerAPI.logWarning("No such iron engine fuel: " + fluid.getName());
}
}
@ZenMethod
public static void addCombustionEngineCoolant(ILiquidStack coolant, float coolingPerMB) {
MineTweakerAPI.apply(new AddLiquidCoolantAction(coolant.getName(), new MTCoolant(coolingPerMB)));
}
@ZenMethod
public static void addCoolantItem(IItemStack coolantItem, ILiquidStack coolantLiquid) {
MineTweakerAPI.apply(new AddCoolantItemAction(new StackWrapper(MineTweakerMC.getItemStack(coolantItem)), MineTweakerMC.getLiquidStack(coolantLiquid)));
}
@ZenMethod
public static void removeCombustionEngineCoolant(ILiquidStack coolant) {
FluidStack fluid = MineTweakerMC.getLiquidStack(coolant);
if (IronEngineCoolant.isCoolant(fluid.getFluid())) {
MineTweakerAPI.apply(new RemoveLiquidCoolantAction(fluid.getFluid().getName(), IronEngineCoolant.getCoolant(fluid)));
} else {
MineTweakerAPI.logWarning("No such iron engine coolant: " + fluid.getFluid().getName());
}
}
@ZenMethod
public static void removeCoolantItem(IIngredient item) {
int numRemoved = 0;
for (IItemStack itemStack : item.getItems()) {
StackWrapper key = new StackWrapper(MineTweakerMC.getItemStack(itemStack));
if (IronEngineCoolant.solidCoolants.containsKey(key)) {
MineTweakerAPI.apply(new RemoveCoolantItemAction(key, IronEngineCoolant.solidCoolants.get(key)));
numRemoved++;
}
}
if (numRemoved == 0) {
MineTweakerAPI.logWarning("No such iron engine coolant: " + item);
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddFuelAction implements IUndoableAction {
private final String fuelName;
private final IronEngineFuel.Fuel fuel;
public AddFuelAction(ILiquidStack fuel, double powerPerCycle, int totalBurningTime) {
fuelName = fuel.getName();
IronEngineFuel.Fuel ieFuel = null;
try {
if (CONSTRUCT_FUEL == null)
System.out.println("No constructor for fuel");
ieFuel = (IronEngineFuel.Fuel) CONSTRUCT_FUEL.newInstance(MineTweakerMC.getLiquidStack(fuel).getFluid(), (float) powerPerCycle, totalBurningTime);
} catch (InstantiationException ex) {
Logger.getLogger(Fuels.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Fuels.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(Fuels.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(Fuels.class.getName()).log(Level.SEVERE, null, ex);
}
this.fuel = ieFuel;
}
@Override
public void apply() {
IronEngineFuel.fuels.put(fuelName, fuel);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
IronEngineFuel.fuels.remove(fuelName);
}
@Override
public String describe() {
return "Adding iron engine fuel " + fuelName;
}
@Override
public String describeUndo() {
return "Removing iron engine fuel " + fuelName;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class RemoveFuelAction implements IUndoableAction {
private final String fuelName;
private final IronEngineFuel.Fuel fuel;
public RemoveFuelAction(String fuelName, IronEngineFuel.Fuel fuel) {
this.fuelName = fuelName;
this.fuel = fuel;
}
@Override
public void apply() {
IronEngineFuel.fuels.remove(fuelName);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
IronEngineFuel.fuels.put(fuelName, fuel);
}
@Override
public String describe() {
return "Removing iron engine fuel " + fuelName;
}
@Override
public String describeUndo() {
return "Restoring iron engine fuel " + fuelName;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class AddLiquidCoolantAction implements IUndoableAction {
private final String liquid;
private final IronEngineCoolant.Coolant coolant;
public AddLiquidCoolantAction(String liquid, IronEngineCoolant.Coolant coolant) {
this.liquid = liquid;
this.coolant = coolant;
}
@Override
public void apply() {
IronEngineCoolant.liquidCoolants.put(liquid, coolant);
}
@Override
public boolean canUndo() {
return false;
}
@Override
public void undo() {
IronEngineCoolant.liquidCoolants.remove(liquid);
}
@Override
public String describe() {
return "Adding iron engine coolant " + liquid;
}
@Override
public String describeUndo() {
return "Removing iron engine coolant " + liquid;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class AddCoolantItemAction implements IUndoableAction {
private final StackWrapper item;
private final FluidStack liquid;
public AddCoolantItemAction(StackWrapper item, FluidStack liquid) {
this.item = item;
this.liquid = liquid;
}
@Override
public void apply() {
IronEngineCoolant.solidCoolants.put(item, liquid);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
IronEngineCoolant.solidCoolants.remove(item);
}
@Override
public String describe() {
return "Adding iron engine coolant item " + MineTweakerMC.getIItemStack(item.stack);
}
@Override
public String describeUndo() {
return "Removing iron engine coolant item " + MineTweakerMC.getIItemStack(item.stack);
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class RemoveLiquidCoolantAction implements IUndoableAction {
private final String liquid;
private final IronEngineCoolant.Coolant coolant;
public RemoveLiquidCoolantAction(String liquid, IronEngineCoolant.Coolant coolant) {
this.liquid = liquid;
this.coolant = coolant;
}
@Override
public void apply() {
IronEngineCoolant.liquidCoolants.remove(liquid);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
IronEngineCoolant.liquidCoolants.put(liquid, coolant);
}
@Override
public String describe() {
return "Removing iron engine coolant " + liquid;
}
@Override
public String describeUndo() {
return "Restoring iron engine coolant " + liquid;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class RemoveCoolantItemAction implements IUndoableAction {
private final StackWrapper item;
private final FluidStack liquid;
public RemoveCoolantItemAction(StackWrapper item, FluidStack liquid) {
this.item = item;
this.liquid = liquid;
}
@Override
public void apply() {
IronEngineCoolant.solidCoolants.remove(item);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
IronEngineCoolant.solidCoolants.put(item, liquid);
}
@Override
public String describe() {
return "Removing iron engine coolant item " + item.stack.getDisplayName();
}
@Override
public String describeUndo() {
return "Restoring iron engine coolant item " + item.stack.getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class MTCoolant implements IronEngineCoolant.Coolant {
private final float coolingPerMB;
public MTCoolant(float coolingPerMB) {
this.coolingPerMB = coolingPerMB;
}
@Override
public float getDegreesCoolingPerMB(float f) {
return coolingPerMB;
}
}
}
@@ -1,200 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mods.buildcraft;
import buildcraft.api.recipes.RefineryRecipes;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.minecraft.MineTweakerMC;
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;
/**
*
* @author Stan
*/
@ZenClass("mods.buildcraft.Refinery")
@ModOnly("BuildCraft|Core")
public class Refinery {
private static final Constructor CONSTRUCT_REFINERYRECIPE;
private static final Field REFINERYRECIPEMANAGER_RECIPES;
static {
Constructor constructor = null;
try {
constructor = RefineryRecipes.Recipe.class.getDeclaredConstructor(FluidStack.class, FluidStack.class, FluidStack.class, int.class, int.class);
constructor.setAccessible(true);
} catch (NoSuchMethodException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
}
Field recipes = null;
try {
recipes = RefineryRecipes.class.getDeclaredField("recipes");
recipes.setAccessible(true);
} catch (NoSuchFieldException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
}
CONSTRUCT_REFINERYRECIPE = constructor;
REFINERYRECIPEMANAGER_RECIPES = recipes;
}
@ZenMethod
public static void addRecipe(ILiquidStack output, int energyPerMB, int ticksPerMB, ILiquidStack input1, @Optional ILiquidStack input2) {
MineTweakerAPI.apply(new AddRecipeAction(output, energyPerMB, ticksPerMB, input1, input2));
}
@ZenMethod
public static void remove(ILiquidStack output) {
Fluid fluid = MineTweakerMC.getLiquidStack(output).getFluid();
List<RefineryRecipes.Recipe> toRemove = new ArrayList<RefineryRecipes.Recipe>();
for (RefineryRecipes.Recipe recipe : RefineryRecipes.getRecipes()) {
if (recipe.result.getFluid() == fluid) {
toRemove.add(recipe);
}
}
for (RefineryRecipes.Recipe recipe : toRemove) {
MineTweakerAPI.apply(new RemoveRecipeAction(recipe));
}
}
private static SortedSet<RefineryRecipes.Recipe> getRecipes() {
try {
return (SortedSet<RefineryRecipes.Recipe>) REFINERYRECIPEMANAGER_RECIPES.get(null);
} catch (IllegalArgumentException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
}
throw new RuntimeException("Refinery recipes unavailable");
}
// ######################
// ### Action Classes ###
// ######################
private static class AddRecipeAction implements IUndoableAction {
private final ILiquidStack output;
private final RefineryRecipes.Recipe recipe;
public AddRecipeAction(ILiquidStack output, int energyPerMB, int ticksPerMB, ILiquidStack input1, ILiquidStack input2) {
this.output = output;
RefineryRecipes.Recipe rrecipe = null;
try {
rrecipe = (RefineryRecipes.Recipe) CONSTRUCT_REFINERYRECIPE.newInstance(
MineTweakerMC.getLiquidStack(input1),
MineTweakerMC.getLiquidStack(input2),
MineTweakerMC.getLiquidStack(output),
energyPerMB,
ticksPerMB);
} catch (InstantiationException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(Refinery.class.getName()).log(Level.SEVERE, null, ex);
}
recipe = rrecipe;
}
@Override
public void apply() {
getRecipes().add(recipe);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
getRecipes().add(recipe);
}
@Override
public String describe() {
return "Adding refinery recipe for " + output;
}
@Override
public String describeUndo() {
return "Removing refinery recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class RemoveRecipeAction implements IUndoableAction {
private final RefineryRecipes.Recipe recipe;
public RemoveRecipeAction(RefineryRecipes.Recipe recipe) {
this.recipe = recipe;
}
@Override
public void apply() {
getRecipes().remove(recipe);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
getRecipes().add(recipe);
}
@Override
public String describe() {
return "Removing refinery recipe for "
+ recipe.result.getFluid().getLocalizedName();
}
@Override
public String describeUndo() {
return "Restoring refinery recipe for "
+ recipe.result.getFluid().getLocalizedName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,43 +0,0 @@
import minetweaker.tasks.RegisterZenClassesTask;
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'forge'
minecraft {
version = forgeVersion164
}
version = "1.0"
archivesBaseName = project.projectDir.name
dependencies {
compile project(':ZenScript')
compile project(':MineTweaker3-API')
compile project(':MineTweaker3-MC164-Main')
compile files('libs/gregtechmod408s.jar')
}
task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main')
outputDir = file('build/classes/main')
className = 'minetweaker.mods.gregtech.ClassRegistry'
}
tasks.jar.dependsOn(makeRegistry)
@@ -1,111 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provider access to the Alloy Smelter recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.AlloySmelter")
@ModOnly("gregtech_addon")
public class AlloySmelter {
/**
* Adds an alloy smelter recipe.
*
* @param output alloy smelter output
* @param input1 primary input
* @param input2 secondary input
* @param durationTicks smelting time, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input1;
private final IItemStack input2;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input1, IItemStack input2, int duration, int euPerTick) {
this.output = output;
this.input1 = input1;
this.input2 = input2;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addAlloySmelterRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding alloy smelter recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 53 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 53 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 53 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
hash = 53 * hash + this.duration;
hash = 53 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,111 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the assembler recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Assembler")
@ModOnly("gregtech_addon")
public class Assembler {
/**
* Adds an assemble recipe.
*
* @param output recipe output
* @param input1 primary input
* @param input2 secondary input (optional, can be null)
* @param durationTicks assembling duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input1;
private final IItemStack input2;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input1, IItemStack input2, int duration, int euPerTick) {
this.output = output;
this.input1 = input1;
this.input2 = input2;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addAssemblerRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding assembler recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 79 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 79 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
hash = 79 * hash + this.duration;
hash = 79 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,145 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Blast Furnace recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.BlastFurnace")
@ModOnly("gregtech_addon")
public class BlastFurnace {
/**
* Adds a recipe with a single output.
*
* @param output recipe output
* @param input1 primary input
* @param input2 secondary input (optional, can be null)
* @param durationTicks crafting duration, in ticks
* @param euPerTick eu consumption per tick
* @param heat required heat capacity
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick, int heat) {
MineTweakerAPI.apply(new AddRecipeAction(input1, input2, output, null, durationTicks, euPerTick, heat));
}
/**
* Adds a recipe with multiple outputs.
*
* @param output array with 1 or 2 outputs
* @param input1 primary input
* @param input2 secondary input (optional, can be null)
* @param durationTicks crafting duration, in ticks
* @param euPerTick eu consumption per tick
* @param heat required heat capacity
*/
@ZenMethod
public static void addRecipe(IItemStack[] output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick, int heat) {
if (output.length == 0) {
MineTweakerAPI.logError("Blast furnace recipe requires at least 1 input");
} else {
MineTweakerAPI.apply(new AddRecipeAction(input1, input2, output[0], output.length > 1 ? output[1] : null, durationTicks, euPerTick, heat));
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack input1;
private final IItemStack input2;
private final IItemStack output1;
private final IItemStack output2;
private final int duration;
private final int euPerTick;
private final int heat;
public AddRecipeAction(IItemStack input1, IItemStack input2, IItemStack output1, IItemStack output2, int duration, int euPerTick, int heat) {
this.input1 = input1;
this.input2 = input2;
this.output1 = output1;
this.output2 = output2;
this.duration = duration;
this.euPerTick = euPerTick;
this.heat = heat;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addBlastRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(output1),
MineTweakerMC.getItemStack(output2),
duration,
euPerTick,
heat);
}
@Override
public String describe() {
return "Adding blast furnace recipe for " + output1;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 89 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
hash = 89 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
hash = 89 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
hash = 89 * hash + this.duration;
hash = 89 * hash + this.euPerTick;
hash = 89 * hash + this.heat;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
return false;
}
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
if (this.heat != other.heat) {
return false;
}
return true;
}
}
}
@@ -1,103 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the CNC recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.CNC")
@ModOnly("gregtech_addon")
public class CNC {
/**
* Adds a CNC recipe.
*
* @param output recipe output
* @param input recipe input
* @param durationTicks crafting duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
this.output = output;
this.input = input;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addCNCRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding CNC recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 53 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 53 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 53 * hash + this.duration;
hash = 53 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,136 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provider access to the Canner recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Canner")
@ModOnly("gregtech_addon")
public class Canner {
/**
* Adds a canner recipe with a single output.
*
* @param output crafting output
* @param input1 primary input
* @param input2 secondary input (optional
* @param durationTicks crafting duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, null, input1, input2, durationTicks, euPerTick));
}
/**
* Adds a canner recipe with multiple outputs.
*
* @param output array with 1 or 2 outputs
* @param input1 primary input
* @param input2 secondary input (optional, can be null)
* @param durationTicks crafting duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack[] output, IItemStack input1, IItemStack input2, int durationTicks, int euPerTick) {
if (output.length == 0) {
MineTweakerAPI.logError("canner requires at least 1 output");
} else {
MineTweakerAPI.apply(new AddRecipeAction(output[0], output.length > 1 ? output[1] : null, input1, input2, durationTicks, euPerTick));
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output1;
private final IItemStack output2;
private final IItemStack input1;
private final IItemStack input2;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack input1, IItemStack input2, int duration, int euPerTick) {
this.output1 = output1;
this.output2 = output2;
this.input1 = input1;
this.input2 = input2;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addCannerRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(output1),
MineTweakerMC.getItemStack(output2),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding canner recipe for " + output1;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
hash = 79 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
hash = 79 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 79 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
hash = 79 * hash + this.duration;
hash = 79 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
return false;
}
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,126 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
*
* @author Stan
*/
@ZenClass("mods.gregtech.Centrifuge")
@ModOnly("gregtech_addon")
public class Centrifuge {
/**
* Adds a centrifuge recipe.
*
* @param outputs array with 1-4 outputs
* @param input recipe input
* @param cells number of cells required, can be 0
* @param durationTicks centrifuging time, in ticks
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IItemStack input, int cells, int durationTicks) {
if (outputs.length < 1) {
MineTweakerAPI.logError("centrifuge must have at least 1 output");
} else {
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, cells, durationTicks));
}
}
/**
* Adds a centrifuge recipe taking a fuel can as container.
*
* @param outputs array with 1-4 outputs
* @param input recipe input
* @param duration centrifuging time, in ticks
*/
@ZenMethod
public static void addRecipeFuelCan(IItemStack[] outputs, IItemStack input, int duration) {
if (outputs.length < 1) {
MineTweakerAPI.logError("centrifuge must have at least 1 output");
} else {
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, -1, duration));
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack[] output;
private final IItemStack input;
private final int cells;
private final int duration;
public AddRecipeAction(IItemStack[] output, IItemStack input, int cells, int duration) {
this.output = output;
this.input = input;
this.cells = cells;
this.duration = duration;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addCentrifugeRecipe(
MineTweakerMC.getItemStack(input),
cells,
MineTweakerMC.getItemStack(output[0]),
output.length > 1 ? MineTweakerMC.getItemStack(output[1]) : null,
output.length > 2 ? MineTweakerMC.getItemStack(output[2]) : null,
output.length > 3 ? MineTweakerMC.getItemStack(output[3]) : null,
duration);
}
@Override
public String describe() {
return "Adding centrifuge recipe with input " + input;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + Arrays.deepHashCode(this.output);
hash = 59 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 59 * hash + this.cells;
hash = 59 * hash + this.duration;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (!Arrays.deepEquals(this.output, other.output)) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.cells != other.cells) {
return false;
}
if (this.duration != other.duration) {
return false;
}
return true;
}
}
}
@@ -1,103 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Chemical Reactor recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.ChemicalReactor")
@ModOnly("gregtech_addon")
public class ChemicalReactor {
/**
* Adds a Chemical Reactor recipe.
*
* @param output recipe output
* @param input1 primary input
* @param input2 secondary input
* @param durationTicks reaction time, in ticks
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks) {
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input1;
private final IItemStack input2;
private final int duration;
public AddRecipeAction(IItemStack output, IItemStack input1, IItemStack input2, int duration) {
this.output = output;
this.input1 = input1;
this.input2 = input2;
this.duration = duration;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addChemicalRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(output),
duration);
}
@Override
public String describe() {
return "Adding chemical reactor recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 11 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 11 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 11 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
hash = 11 * hash + this.duration;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
return true;
}
}
}
@@ -1,86 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the computer cube descriptions.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.ComputerCube")
@ModOnly("gregtech_addon")
public class ComputerCube {
/**
* Adds a description entry to the computer cube.
*
* @param items items to be displayed
* @param text text to be displayed
*/
@ZenMethod
public static void addDescriptionSet(IItemStack[] items, String[] text) {
MineTweakerAPI.apply(new AddDescriptionAction(items, text));
}
// ######################
// ### Action classes ###
// ######################
private static class AddDescriptionAction extends OneWayAction {
private final IItemStack[] items;
private final String[] text;
public AddDescriptionAction(IItemStack[] items, String[] text) {
this.items = items;
this.text = text;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addComputercubeDescriptionSet(MineTweakerMC.getItemStacks(items), text);
}
@Override
public String describe() {
return "Adding computer cube descriptions";
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 3;
hash = 11 * hash + Arrays.deepHashCode(this.items);
hash = 11 * hash + Arrays.deepHashCode(this.text);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddDescriptionAction other = (AddDescriptionAction) obj;
if (!Arrays.deepEquals(this.items, other.items)) {
return false;
}
if (!Arrays.deepEquals(this.text, other.text)) {
return false;
}
return true;
}
}
}
@@ -1,132 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the distillation tower recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.DistillationTower")
@ModOnly("gregtech_addon")
public class DistillationTower {
/**
* Adds a distillation tower recipe with a single output.
*
* @param output recipe output
* @param input recipe input
* @param cells number of cells required (can be 0)
* @param durationTicks distillation time, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int cells, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(new IItemStack[] { output }, input, cells, durationTicks, euPerTick));
}
/**
* Adds a distillation tower recipe with multiple outputs.
*
* @param outputs array with 1-4 outputs
* @param input recipe input
* @param cells number of cells required (can be 0)
* @param durationTicks distillation time, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IItemStack input, int cells, int durationTicks, int euPerTick) {
if (outputs.length == 0) {
MineTweakerAPI.logError("Distillation tower recipe requires at least 1 output");
} else {
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, cells, durationTicks, euPerTick));
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack[] outputs;
private final IItemStack input;
private final int cells;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack[] outputs, IItemStack input, int cells, int duration, int euPerTick) {
this.outputs = outputs;
this.input = input;
this.cells = cells;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addDistillationRecipe(
MineTweakerMC.getItemStack(input),
cells,
MineTweakerMC.getItemStack(outputs[0]),
outputs.length > 1 ? MineTweakerMC.getItemStack(outputs[1]) : null,
outputs.length > 2 ? MineTweakerMC.getItemStack(outputs[2]) : null,
outputs.length > 3 ? MineTweakerMC.getItemStack(outputs[3]) : null,
duration, euPerTick);
}
@Override
public String describe() {
return "Adding Distillation tower recipe for " + outputs[0];
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 3;
hash = 41 * hash + Arrays.deepHashCode(this.outputs);
hash = 41 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 41 * hash + this.cells;
hash = 41 * hash + this.duration;
hash = 41 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (!Arrays.deepEquals(this.outputs, other.outputs)) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.cells != other.cells) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,119 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Electrolyzer recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Electrolyzer")
@ModOnly("gregtech_addon")
public class Electrolyzer {
/**
* Adds an electrolyzer recipe.
*
* @param outputs array with 1-4 outputs
* @param input recipe input
* @param cells number of cells required (can be 0)
* @param durationTicks electrolyzing duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IItemStack input, int cells, int durationTicks, int euPerTick) {
if (outputs.length < 1) {
MineTweakerAPI.logError("Electrolyzer recipe requires at least 1 output");
} else {
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, cells, durationTicks, euPerTick));
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack[] output;
private final IItemStack input;
private final int cells;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack[] output, IItemStack input, int cells, int duration, int euPerTick) {
this.output = output;
this.input = input;
this.cells = cells;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addElectrolyzerRecipe(
MineTweakerMC.getItemStack(input),
cells,
MineTweakerMC.getItemStack(output[0]),
output.length > 1 ? MineTweakerMC.getItemStack(output[1]) : null,
output.length > 2 ? MineTweakerMC.getItemStack(output[2]) : null,
output.length > 3 ? MineTweakerMC.getItemStack(output[3]) : null,
duration,
cells);
}
@Override
public String describe() {
return "Adding electrolyzer recipe with input " + input;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 97 * hash + Arrays.deepHashCode(this.output);
hash = 97 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 97 * hash + this.cells;
hash = 97 * hash + this.duration;
hash = 97 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (!Arrays.deepEquals(this.output, other.output)) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.cells != other.cells) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,111 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the extruder recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Extruder")
@ModOnly("gregtech_addon")
public class Extruder {
/**
* Adds an extruder recipe.
*
* @param output recipe output
* @param input recipe input
* @param shape shape (set stack size to 0 to prevent the shape from being consumed)
* @param durationTicks extruding time, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, IItemStack shape, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, shape, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input;
private final IItemStack shape;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input, IItemStack shape, int duration, int euPerTick) {
this.output = output;
this.input = input;
this.shape = shape;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addExtruderRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(shape),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding extruder recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 67 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 67 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 67 * hash + (this.shape != null ? this.shape.hashCode() : 0);
hash = 67 * hash + this.duration;
hash = 67 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.shape != other.shape && (this.shape == null || !this.shape.equals(other.shape))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,103 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Forge Hammer recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.ForgeHammer")
@ModOnly("gregtech_addon")
public class ForgeHammer {
/**
* Add a Forge Hammer recipe.
*
* @param output recipe output
* @param input recipe input
* @param durationTicks forging duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
this.output = output;
this.input = input;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addForgeHammerRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding forge hammer recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 97 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 97 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 97 * hash + this.duration;
hash = 97 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,177 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the fuels used by the various generators.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Fuels")
@ModOnly("gregtech_addon")
public class Fuels {
/**
* Adds a Diesel Engine fuel. If the given item does not contain any liquid,
* it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
public static void addDieselFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 0));
}
/**
* Adds a Gas Turbine fuel. If the given item does not contain any liquid,
* it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
public static void addGasTurbineFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 1));
}
/**
* Adds a Thermal Generator fuel. If the given item does not contain any
* liquid, it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
public static void addThermalGeneratorFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 2));
}
/**
* Adds a Dense Fluid Generator fuel. If the given item does not contain any
* liquid, it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
public static void addDenseFluidFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 3));
}
/**
* Adds a Plasma Generator fuel. If the given item does not contain any
* liquid, it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
public static void addPlasmaGeneratorFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 4));
}
/**
* Adds a Magic Generator fuel. If the given item does not contain any liquid,
* it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
public static void addMagicGeneratorFuel(IItemStack output, IItemStack input, int euPerMillibucket) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, euPerMillibucket, 5));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private static final String[] GENERATORS = {
"diesel",
"gas turbine",
"thermal",
"dense fluid",
"plasma",
"magic"
};
private final IItemStack output;
private final IItemStack input;
private final int euPerMillibucket;
private final int type;
public AddRecipeAction(IItemStack output, IItemStack input, int euPerMillibucket, int type) {
this.output = output;
this.input = input;
this.euPerMillibucket = euPerMillibucket;
this.type = type;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addFuel(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
euPerMillibucket,
type);
}
@Override
public String describe() {
return "Adding " + GENERATORS[type] + " fuel " + input;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 59 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 59 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 59 * hash + this.euPerMillibucket;
hash = 59 * hash + this.type;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.euPerMillibucket != other.euPerMillibucket) {
return false;
}
if (this.type != other.type) {
return false;
}
return true;
}
}
}
@@ -1,125 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the fusion reactor recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.FusionReactor")
@ModOnly("gregtech_addon")
public class FusionReactor {
/**
* Adds a Fusion Reactor recipe.
*
* @param output reactor output
* @param input1 primary input
* @param input2 secondary input
* @param durationTicks fusion duration, in ticks
* @param energyPerTick eu consumption per tick
* @param startEnergy starting energy
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, IItemStack input2, int durationTicks, int energyPerTick, int startEnergy) {
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, energyPerTick, startEnergy));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input1;
private final IItemStack input2;
private final int durationTicks;
private final int energyPerTick;
private final int startEnergy;
public AddRecipeAction(
IItemStack output,
IItemStack input1,
IItemStack input2,
int durationTicks,
int energyPerTick,
int startEnergy) {
this.output = output;
this.input1 = input1;
this.input2 = input2;
this.durationTicks = durationTicks;
this.energyPerTick = energyPerTick;
this.startEnergy = startEnergy;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addFusionReactorRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(output),
durationTicks,
energyPerTick,
startEnergy);
}
@Override
public String describe() {
return "Adding fusion reactor recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 97 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 97 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 97 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
hash = 97 * hash + this.durationTicks;
hash = 97 * hash + this.energyPerTick;
hash = 97 * hash + this.startEnergy;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
if (this.durationTicks != other.durationTicks) {
return false;
}
if (this.energyPerTick != other.energyPerTick) {
return false;
}
if (this.startEnergy != other.startEnergy) {
return false;
}
return true;
}
}
}
@@ -1,115 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import gregtechmod.api.util.GT_ModHandler;
import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Grinder recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Grinder")
@ModOnly("gregtech_addon")
public class Grinder {
/**
* Adds a recipe with a single output.
*
* @param output grinder output
* @param input1 grinder primary input
* @param input2 grinder liquid input (optional, will use 1 water cell if set to null)
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, @Optional IItemStack input2) {
if (input2 == null) input2 = MineTweakerMC.getIItemStack(GT_ModHandler.getWaterCell(1));
MineTweakerAPI.apply(new AddRecipeAction(new IItemStack[] { output }, input1, input2));
}
/**
* Adds a recipe with multiple outputs.
*
* @param outputs array with 1-4 outputs
* @param input1 grinder primary input
* @param input2 grinder liquid input (optional, will use 1 water cell if set to null)
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IItemStack input1, @Optional IItemStack input2) {
if (input2 == null) input2 = MineTweakerMC.getIItemStack(GT_ModHandler.getWaterCell(1));
MineTweakerAPI.apply(new AddRecipeAction(outputs, input1, input2));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack[] outputs;
private final IItemStack input1;
private final IItemStack input2;
private AddRecipeAction(IItemStack[] outputs, IItemStack input1, IItemStack input2) {
this.outputs = outputs;
this.input1 = input1;
this.input2 = input2;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addGrinderRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(outputs[0]),
outputs.length > 1 ? MineTweakerMC.getItemStack(outputs[1]) : null,
outputs.length > 2 ? MineTweakerMC.getItemStack(outputs[2]) : null,
outputs.length > 3 ? MineTweakerMC.getItemStack(outputs[3]) : null);
}
@Override
public String describe() {
return "Adding grinder recipe for " + outputs[0];
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 89 * hash + Arrays.deepHashCode(this.outputs);
hash = 89 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 89 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (!Arrays.deepEquals(this.outputs, other.outputs)) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
return true;
}
}
}
@@ -1,118 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Implosion Compressor recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.ImplosionCompressor")
@ModOnly("gregtech_addon")
public class ImplosionCompressor {
/**
* Adds an implosion compressor recipe with a single output.
*
* @param output recipe output
* @param input primary input
* @param tnt amount of TNT needed
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int tnt) {
MineTweakerAPI.apply(new AddRecipeAction(output, null, input, tnt));
}
/**
* Adds an implosion compressor recipe with one or two outputs.
*
* @param output array with 1-2 outputs
* @param input primary input
* @param tnt amount of TNT needed
*/
@ZenMethod
public static void addRecipe(IItemStack[] output, IItemStack input, int tnt) {
if (output.length == 0) {
MineTweakerAPI.logError("Implosion compressor recipe requires at least 1 output");
} else {
MineTweakerAPI.apply(new AddRecipeAction(output[0], output.length > 1 ? output[1] : null, input, tnt));
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output1;
private final IItemStack output2;
private final IItemStack input1;
private final int tnt;
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack input1, int tnt) {
this.output1 = output1;
this.output2 = output2;
this.input1 = input1;
this.tnt = tnt;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addImplosionRecipe(
MineTweakerMC.getItemStack(input1),
tnt,
MineTweakerMC.getItemStack(output1),
MineTweakerMC.getItemStack(output2));
}
@Override
public String describe() {
return "Adding Implosion compressor recipe for " + output1;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 97 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
hash = 97 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
hash = 97 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 97 * hash + this.tnt;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
return false;
}
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.tnt != other.tnt) {
return false;
}
return true;
}
}
}
@@ -1,116 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Access point to jack hammer whitelist.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.JackHammer")
@ModOnly("gregtech_addon")
public class JackHammer {
/**
* Adds a block to be minable. The given item must be a block.
*
* @param item block
*/
@ZenMethod
public static void addMinableBlock(IItemStack item) {
Block block = getBlock(item);
if (block == null) {
MineTweakerAPI.logError("Not a block: " + item);
} else {
MineTweakerAPI.apply(new AddBlockAction(block, false));
}
}
/**
* Adds a block to be minable, but only with the diamond tools. The given
* item must be a block.
*
* @param item block
*/
@ZenMethod
public static void addDiamondMinableBlock(IItemStack item) {
Block block = getBlock(item);
if (block == null) {
MineTweakerAPI.logError("Not a block: " + item);
} else {
MineTweakerAPI.apply(new AddBlockAction(block, true));
}
}
// #######################
// ### Private Methods ###
// #######################
private static Block getBlock(IItemStack item) {
ItemStack itemStack = MineTweakerMC.getItemStack(item);
return itemStack.itemID > Block.blocksList.length ? null : Block.blocksList[itemStack.itemID];
}
// ######################
// ### Action classes ###
// ######################
private static class AddBlockAction extends OneWayAction {
private final Block block;
private final boolean diamondOnly;
public AddBlockAction(Block block, boolean diamondOnly) {
this.block = block;
this.diamondOnly = diamondOnly;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addJackHammerMinableBlock(block, diamondOnly);
}
@Override
public String describe() {
return "Adding jackhammer mineable block " + block;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 83 * hash + (this.block != null ? this.block.hashCode() : 0);
hash = 83 * hash + (this.diamondOnly ? 1 : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddBlockAction other = (AddBlockAction) obj;
if (this.block != other.block) {
return false;
}
if (this.diamondOnly != other.diamondOnly) {
return false;
}
return true;
}
}
}
@@ -1,132 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Access point for Lathe recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Lathe")
@ModOnly("gregtech_addon")
public class Lathe {
/**
* Adds a lathe recipe with a single output.
*
* @param output recipe output
* @param input recipe input
* @param durationTicks crafting duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, null, input, durationTicks, euPerTick));
}
/**
* Adds a lathe recipe with 1 or 2 outputs.
*
* @param outputs array with 1-2 outputs
* @param input recipe input
* @param durationTicks crafting duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IItemStack input, int durationTicks, int euPerTick) {
if (outputs.length == 0) {
MineTweakerAPI.logError("Lathe recipe requires at least 1 input");
} else {
MineTweakerAPI.apply(new AddRecipeAction(
outputs[0],
outputs.length > 1 ? outputs[1] : null,
input,
durationTicks,
euPerTick));
}
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output1;
private final IItemStack output2;
private final IItemStack input;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack input, int duration, int euPerTick) {
this.output1 = output1;
this.output2 = output2;
this.input = input;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addLatheRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output1),
MineTweakerMC.getItemStack(output2),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding lathe recipe for " + output1;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 53 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
hash = 53 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
hash = 53 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 53 * hash + this.duration;
hash = 53 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
return false;
}
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,103 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Access point to Plate Bender recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.PlateBender")
@ModOnly("gregtech_addon")
public class PlateBender {
/**
* Adds a plate bender recipe.
*
* @param output recipe output
* @param input recipe input
* @param durationTicks bending time, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
this.output = output;
this.input = input;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addBenderRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding plate bender recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 79 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 79 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 79 * hash + this.duration;
hash = 79 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,103 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Plate Cutter recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.PlateCutter")
@ModOnly("gregtech_addon")
public class PlateCutter {
/**
* Adds a plate cutter recipe.
*
* @param output recipe output
* @param input recipe input
* @param durationTicks cutting time, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
this.output = output;
this.input = input;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addCutterRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding plate cutter recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 17 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 17 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 17 * hash + this.duration;
hash = 17 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
@@ -1,130 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import gregtechmod.api.util.GT_ModHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Sawmill recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Sawmill")
@ModOnly("gregtech_addon")
public class Sawmill {
/**
* Adds a new sawmill recipe.
*
* @param output recipe output
* @param input1 primary input
* @param input2 secondary input (optional, if set to null will use a water cell)
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input1, @Optional IItemStack input2) {
if (input2 == null) input2 = MineTweakerMC.getIItemStack(GT_ModHandler.getWaterCell(1));
MineTweakerAPI.apply(new AddRecipeAction(output, null, null, input1, input2));
}
/**
* Adds a new sawmill recipe with 1-3 outputs.
*
* @param outputs array with 1-3 outputs
* @param input1 primary input
* @param input2 secondary input (optional, if set to null will use a water cell)
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IItemStack input1, @Optional IItemStack input2) {
if (input2 == null) input2 = MineTweakerMC.getIItemStack(GT_ModHandler.getWaterCell(1));
MineTweakerAPI.apply(new AddRecipeAction(
outputs[0],
outputs.length > 1 ? outputs[1] : null,
outputs.length > 2 ? outputs[2] : null,
input1,
input2));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output1;
private final IItemStack output2;
private final IItemStack output3;
private final IItemStack input1;
private final IItemStack input2;
public AddRecipeAction(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack input1, IItemStack input2) {
this.output1 = output1;
this.output2 = output2;
this.output3 = output3;
this.input1 = input1;
this.input2 = input2;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addSawmillRecipe(
MineTweakerMC.getItemStack(input1),
MineTweakerMC.getItemStack(input2),
MineTweakerMC.getItemStack(output1),
MineTweakerMC.getItemStack(output2),
MineTweakerMC.getItemStack(output3));
}
@Override
public String describe() {
return "Adding Sawmill recipe for " + output1;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 23 * hash + (this.output1 != null ? this.output1.hashCode() : 0);
hash = 23 * hash + (this.output2 != null ? this.output2.hashCode() : 0);
hash = 23 * hash + (this.output3 != null ? this.output3.hashCode() : 0);
hash = 23 * hash + (this.input1 != null ? this.input1.hashCode() : 0);
hash = 23 * hash + (this.input2 != null ? this.input2.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output1 != other.output1 && (this.output1 == null || !this.output1.equals(other.output1))) {
return false;
}
if (this.output2 != other.output2 && (this.output2 == null || !this.output2.equals(other.output2))) {
return false;
}
if (this.output3 != other.output3 && (this.output3 == null || !this.output3.equals(other.output3))) {
return false;
}
if (this.input1 != other.input1 && (this.input1 == null || !this.input1.equals(other.input1))) {
return false;
}
if (this.input2 != other.input2 && (this.input2 == null || !this.input2.equals(other.input2))) {
return false;
}
return true;
}
}
}
@@ -1,87 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the sonictron.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Sonictron")
@ModOnly("gregtech_addon")
public class Sonictron {
/**
* Adds a sonictron sound.
*
* @param itemStack item you want to display for this sound
* @param soundName name of the Sound in the resources/newsound-folder like Vanillasounds
*/
@ZenMethod
public static void addSound(IItemStack itemStack, String soundName) {
MineTweakerAPI.apply(new AddSoundAction(itemStack, soundName));
}
// ######################
// ### Action classes ###
// ######################
private static class AddSoundAction extends OneWayAction {
private final IItemStack itemStack;
private final String soundName;
public AddSoundAction(IItemStack itemStack, String soundName) {
this.itemStack = itemStack;
this.soundName = soundName;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addSonictronSound(
MineTweakerMC.getItemStack(itemStack),
soundName);
}
@Override
public String describe() {
return "Adding sonictron sound " + soundName;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + (this.itemStack != null ? this.itemStack.hashCode() : 0);
hash = 79 * hash + (this.soundName != null ? this.soundName.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddSoundAction other = (AddSoundAction) obj;
if (this.itemStack != other.itemStack && (this.itemStack == null || !this.itemStack.equals(other.itemStack))) {
return false;
}
if ((this.soundName == null) ? (other.soundName != null) : !this.soundName.equals(other.soundName)) {
return false;
}
return true;
}
}
}
@@ -1,95 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Vacuum Freezer recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.VacuumFreezer")
@ModOnly("gregtech_addon")
public class VacuumFreezer {
/**
* Adds a vacuum freezer recipe.
*
* @param output recipe output
* @param input recipe input
* @param durationTicks freezing duration, in ticks
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input;
private final int duration;
public AddRecipeAction(IItemStack output, IItemStack input, int duration) {
this.output = output;
this.input = input;
this.duration = duration;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addVacuumFreezerRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
duration);
}
@Override
public String describe() {
return "Adding vacuum freezer recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 67 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 67 * hash + this.duration;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
return true;
}
}
}
@@ -1,103 +0,0 @@
package minetweaker.mods.gregtech.machines;
import gregtechmod.api.GregTech_API;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Provides access to the Wiremill recipes.
*
* @author Stan Hebben
*/
@ZenClass("mods.gregtech.Wiremill")
@ModOnly("gregtech_addon")
public class Wiremill {
/**
* Adds a Wiremill recipe.
*
* @param output recipe output
* @param input recipe input
* @param durationTicks processing time
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input, durationTicks, euPerTick));
}
// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends OneWayAction {
private final IItemStack output;
private final IItemStack input;
private final int duration;
private final int euPerTick;
public AddRecipeAction(IItemStack output, IItemStack input, int duration, int euPerTick) {
this.output = output;
this.input = input;
this.duration = duration;
this.euPerTick = euPerTick;
}
@Override
public void apply() {
GregTech_API.sRecipeAdder.addWiremillRecipe(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
duration,
euPerTick);
}
@Override
public String describe() {
return "Adding wiremill recipe for " + output;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 7;
hash = 37 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 37 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 37 * hash + this.duration;
hash = 37 * hash + this.euPerTick;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.duration != other.duration) {
return false;
}
if (this.euPerTick != other.euPerTick) {
return false;
}
return true;
}
}
}
-42
View File
@@ -1,42 +0,0 @@
import minetweaker.tasks.RegisterZenClassesTask;
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'forge'
minecraft{
version = forgeVersion164
}
version = "1.0"
archivesBaseName = project.projectDir.name
dependencies {
compile project(':ZenScript')
compile project(':MineTweaker3-API')
compile project(':MineTweaker3-MC164-Main')
compile files('libs/industrialcraft-2_2.0.383-experimental.jar')
}
task makeRegistry(type: RegisterZenClassesTask) {
inputDir = file('build/classes/main')
outputDir = file('build/classes/main')
className = 'minetweaker.mods.ic2.ClassRegistry'
}
tasks.jar.dependsOn(makeRegistry)
@@ -1,103 +0,0 @@
package minetweaker.mods.ic2;
import ic2.api.item.Items;
import java.util.List;
import minetweaker.IBracketHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.BracketHandler;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.ZenTokener;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionInt;
import stanhebben.zenscript.expression.ExpressionCallStatic;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.type.ZenType;
import stanhebben.zenscript.type.natives.IJavaMethod;
import stanhebben.zenscript.util.ZenPosition;
/**
* Makes a ic2-item specific item syntax available in the form &lt;item-ic2:name[:meta]&gt;.
*
* @author Stan Hebben
*/
@BracketHandler
@ModOnly("IC2")
public class IC2BracketHandler implements IBracketHandler {
public static IItemStack getItem(String name, int meta) {
ItemStack stack = Items.getItem(name);
stack.setItemDamage(meta);
return getIItemStack(stack);
}
private final IJavaMethod method;
public IC2BracketHandler() {
method = MineTweakerAPI.getJavaMethod(IC2BracketHandler.class, "getItem", String.class, int.class);
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
if (tokens.size() >= 5) {
if (tokens.get(0).getValue().equals("ic2")
&& tokens.get(1).getValue().equals("-")
&& tokens.get(2).getValue().equals("item")
&& tokens.get(3).getValue().equals(":")) {
String name = tokens.get(4).getValue();
int meta = 0;
if (tokens.size() > 6 && tokens.get(5).getValue().equals(":")) {
if (tokens.get(6).getType() == ZenTokener.T_INTVALUE) {
meta = Integer.parseInt(tokens.get(6).getValue());
} else if (tokens.get(6).getValue().equals("*")) {
meta = OreDictionary.WILDCARD_VALUE;
} else {
MineTweakerAPI.logError("Not a valid meta value: " + tokens.get(6).getValue());
}
}
ItemStack item = Items.getItem(name);
if (item == null) {
MineTweakerAPI.logError("Not a valid IC2 item: " + name);
return null;
} else {
return new ItemReferenceSymbol(environment, name, meta);
}
} else {
return null;
}
} else {
return null;
}
}
// #############################
// ### Private inner classes ###
// #############################
private class ItemReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final String name;
private final int meta;
public ItemReferenceSymbol(IEnvironmentGlobal environment, String name, int meta) {
this.environment = environment;
this.name = name;
this.meta = meta;
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionCallStatic(
position,
environment,
method,
new ExpressionString(position, name),
new ExpressionInt(position, meta, ZenType.INT));
}
}
}
@@ -1,167 +0,0 @@
package minetweaker.mods.ic2;
import ic2.api.tile.ExplosionWhitelist;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Manages the explosion whitelist in IC2. Blocks on this whitelist will not resist
* an explosion but won't be destroyed.
*
* The explosion code by default ignores blocks which absorb more than 1000 explosion power to
* prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and
* invulnerable reactor chambers. Said blocks will not shield the explosion and won't get
* destroyed.
*
* @author Stan Hebben
*/
@ZenClass("mods.ic2.ExplosionWhitelist")
@ModOnly("IC2")
public class IC2ExplosionWhitelist {
/**
* Adds a block to the explosion whitelist.
*
* @param item item to add
*/
@ZenMethod
public static void add(IItemStack item) {
ItemStack iStack = getItemStack(item);
Block block = getBlock(iStack.getItem());
if (block == null) {
MineTweakerAPI.logError("This item is not a block");
} else {
MineTweakerAPI.apply(new AddAction(block));
}
}
/**
* Removes a block from the explosion whitelist.
*
* @param item item to remove
*/
@ZenMethod
public static void remove(IItemStack item) {
ItemStack iStack = getItemStack(item);
Block block = getBlock(iStack.getItem());
if (block == null) {
MineTweakerAPI.logError("This item is not a block");
} else {
if (ExplosionWhitelist.isBlockWhitelisted(block)) {
MineTweakerAPI.logWarning("This block is not in the whitelist");
} else {
MineTweakerAPI.apply(new RemoveAction(block));
}
}
}
/**
* Checks if the given item is already whitelisted.
*
* @param item item to check
* @return true if whitelisted
*/
@ZenMethod
public static boolean isWhitelisted(IItemStack item) {
ItemStack iStack = getItemStack(item);
Block block = getBlock(iStack.getItem());
if (block == null) {
MineTweakerAPI.logWarning("This item is not a block");
return false;
} else {
return ExplosionWhitelist.isBlockWhitelisted(block);
}
}
private static Block getBlock(Item item) {
if (item.itemID >= Block.blocksList.length) return null;
return Block.blocksList[item.itemID];
}
// ######################
// ### Action classes ###
// ######################
private static class AddAction implements IUndoableAction {
private final Block block;
public AddAction(Block block) {
this.block = block;
}
@Override
public void apply() {
ExplosionWhitelist.addWhitelistedBlock(block);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
ExplosionWhitelist.removeWhitelistedBlock(block);
}
@Override
public String describe() {
return "Adding block to IC2 explosion whitelist: " + block.getLocalizedName();
}
@Override
public String describeUndo() {
return "Removing block from IC2 explosion whitelist: " + block.getLocalizedName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class RemoveAction implements IUndoableAction {
private final Block block;
public RemoveAction(Block block) {
this.block = block;
}
@Override
public void apply() {
ExplosionWhitelist.removeWhitelistedBlock(block);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
ExplosionWhitelist.addWhitelistedBlock(block);
}
@Override
public String describe() {
return "Removing block from IC2 explosion whitelist: " + block.getLocalizedName();
}
@Override
public String describeUndo() {
return "Adding block to IC2 explosion whitelist: " + block.getLocalizedName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,70 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.mods.ic2;
import ic2.api.recipe.IRecipeInput;
import java.util.ArrayList;
import java.util.List;
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
/**
* Wrapper class for ITweakerItemStackPatterns to IC2 recipe inputs.
*
* @author Stan Hebben
*/
public class IC2RecipeInput implements IRecipeInput {
private final IIngredient ingredient;
public IC2RecipeInput(IIngredient ingredient) {
this.ingredient = ingredient;
}
@Override
public boolean matches(ItemStack subject) {
return ingredient.matches(getIItemStack(subject));
}
@Override
public int getAmount() {
return ingredient.getAmount();
}
@Override
public List<ItemStack> getInputs() {
List<ItemStack> items = new ArrayList<ItemStack>();
for (IItemStack item : ingredient.getItems()) {
items.add(getItemStack(item));
}
return items;
}
@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + (this.ingredient != null ? this.ingredient.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final IC2RecipeInput other = (IC2RecipeInput) obj;
if (this.ingredient != other.ingredient && (this.ingredient == null || !this.ingredient.equals(other.ingredient))) {
return false;
}
return true;
}
}
Loaded 100 of 329 files, more files were not shown because too many files have changed in this diff. Show more