2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.library;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
2014-09-09 18:30:15 +10:00
|
|
|
import java.util.*;
|
|
|
|
|
import net.minecraft.item.*;
|
|
|
|
|
import org.apache.logging.log4j.*;
|
|
|
|
|
import tconstruct.library.crafting.*;
|
2014-06-30 22:26:00 -08:00
|
|
|
import tconstruct.library.modifier.ActiveArmorMod;
|
2014-09-09 18:30:15 +10:00
|
|
|
import tconstruct.library.tools.*;
|
2021-10-03 20:35:19 -06:00
|
|
|
import tconstruct.tools.TinkerTools;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* A registry to store any relevant API work
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2013-07-26 21:18:53 -07:00
|
|
|
* @author mDiyo
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public class TConstructRegistry {
|
2013-07-26 21:18:53 -07:00
|
|
|
public static TConstructRegistry instance = new TConstructRegistry();
|
|
|
|
|
|
2014-02-20 14:20:02 -05:00
|
|
|
public static Logger logger = LogManager.getLogger("TCon-API");
|
2013-10-12 23:46:35 +01:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
/* Creative tabs */
|
2014-07-05 22:06:38 -08:00
|
|
|
public static TConstructCreativeTab toolTab;
|
|
|
|
|
public static TConstructCreativeTab partTab;
|
|
|
|
|
public static TConstructCreativeTab materialTab;
|
|
|
|
|
public static TConstructCreativeTab blockTab;
|
|
|
|
|
public static TConstructCreativeTab equipableTab;
|
2014-10-05 20:46:12 +02:00
|
|
|
public static TConstructCreativeTab weaponryTab;
|
2022-02-20 20:32:57 +00:00
|
|
|
public static TConstructCreativeTab gadgetsTab;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
/* Items */
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* A directory of crafting items and tools used by the mod.
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* Tools: pickaxe, shovel, hatchet, broadsword, longsword, rapier, dagger,
|
|
|
|
|
* cutlass frypan, battlesign, mattock, chisel lumberaxe, cleaver, scythe,
|
|
|
|
|
* excavator, hammer, battleaxe
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2022-09-18 10:57:03 +02:00
|
|
|
* Patterns: blankPattern, woodPattern, metalPattern, clayPattern
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* Tool crafting parts: toolRod, toolShard, binding, toughBinding, toughRod,
|
|
|
|
|
* heavyPlate pickaxeHead, shovelhead, hatchetHead, swordBlade, wideguard,
|
|
|
|
|
* handGuard, crossbar, knifeBlade, fullGuard, frypanHead, signHead,
|
|
|
|
|
* chiselHead scytheBlade, broadAxeHead, excavatorHead, largeSwordBlade,
|
|
|
|
|
* hammerHead bowstring, fletching, arrowhead
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
|
|
|
|
public static HashMap<String, Item> itemDirectory = new HashMap<String, Item>();
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Adds an item to the directory
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param name
|
|
|
|
|
* Associates the name with the stack
|
|
|
|
|
* @param itemstack
|
|
|
|
|
* The stack to add to the directory
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addItemToDirectory(String name, Item itemstack) {
|
2013-07-26 21:18:53 -07:00
|
|
|
Item add = itemDirectory.get(name);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (add != null) logger.warn(name + " is already present in the Item directory");
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
itemDirectory.put(name, itemstack);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Retrieves an itemstack from the directory
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param name
|
|
|
|
|
* The name of the item to get
|
2013-07-26 21:18:53 -07:00
|
|
|
* @return Item associated with the name, or null if not present.
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static Item getItem(String name) {
|
2013-07-26 21:18:53 -07:00
|
|
|
Item ret = itemDirectory.get(name);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (ret == null) logger.warn("Could not find " + name + " in the Item directory");
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* A directory of ItemStacks. Contains mostly crafting items
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* Materials: paperStack, greenSlimeCrystal, blueSlimeCrystal, searedBrick,
|
|
|
|
|
* mossBall, lavaCrystal, necroticBone, silkyCloth, silkyJewel ingotCobalt,
|
|
|
|
|
* ingotArdite, ingotManyullyn, ingotCopper, ingotTin, ingotAluminum,
|
|
|
|
|
* rawAluminum, ingotBronze, ingotAluminumBrass, ingotAlumite, ingotSteel,
|
|
|
|
|
* ingotObsidian nuggetIron, nuggetCopper, nuggetTin, nuggetAluminum,
|
|
|
|
|
* nuggetSilver, nuggetAluminumBrass oreberryIron, oreberryGold,
|
|
|
|
|
* oreberryCopper, oreberryTin, oreberryTin, oreberrySilver, diamondApple,
|
|
|
|
|
* blueSlimeFood, canisterEmpty, miniRedHeart, canisterRedHeart
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2013-07-26 21:18:53 -07:00
|
|
|
* Patterns - These have a suffix of Pattern or Cast. ex: hatchetHeadPattern
|
2014-02-16 14:23:50 -05:00
|
|
|
* ingot, toolRod, pickaxeHead, shovelHead, hatchetHead, swordBlade,
|
|
|
|
|
* wideGuard, handGuard, crossbar, binding, frypanHead, signHead,
|
|
|
|
|
* knifeBlade, chiselHead, toughRod, toughBinding, largePlate, broadAxeHead,
|
2014-09-19 15:38:35 -07:00
|
|
|
* scytheHead, excavatorHead, largeBlade, hammerHead, fullGuard, bowString,
|
|
|
|
|
* fletching, arrowHead
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
|
|
|
|
static HashMap<String, ItemStack> itemstackDirectory = new HashMap<String, ItemStack>();
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Adds an itemstack to the directory
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param name
|
|
|
|
|
* Associates the name with the stack
|
|
|
|
|
* @param itemstack
|
|
|
|
|
* The stack to add to the directory
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addItemStackToDirectory(String name, ItemStack itemstack) {
|
2013-07-26 21:18:53 -07:00
|
|
|
ItemStack add = itemstackDirectory.get(name);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (add != null) logger.warn(name + " is already present in the ItemStack directory");
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
itemstackDirectory.put(name, itemstack);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Retrieves an itemstack from the directory
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param name
|
|
|
|
|
* The name of the item to get
|
2013-07-26 21:18:53 -07:00
|
|
|
* @return Item associated with the name, or null if not present.
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static ItemStack getItemStack(String name) {
|
2013-07-26 21:18:53 -07:00
|
|
|
ItemStack ret = itemstackDirectory.get(name);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (ret == null) logger.warn("Could not find " + name + " in the ItemStack directory");
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ArrayList<ToolCore> tools = new ArrayList<ToolCore>(20);
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Parts
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* List: Item ID, metadata, material ID ItemStack: Output. Ex: Cactus
|
|
|
|
|
* Binding
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
|
|
|
|
public static HashMap<List, ItemStack> patternPartMapping = new HashMap<List, ItemStack>();
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Maps an item and a material ID to an output part
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param woodPattern
|
|
|
|
|
* ID to check against
|
|
|
|
|
* @param patternMeta
|
|
|
|
|
* Metadata to check against
|
|
|
|
|
* @param materialID
|
|
|
|
|
* Material that goes with the item
|
|
|
|
|
* @param output
|
|
|
|
|
* The resulting part
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addPartMapping(Item woodPattern, int patternMeta, int materialID, ItemStack output) {
|
2013-12-31 14:11:05 -05:00
|
|
|
patternPartMapping.put(Arrays.asList(woodPattern, patternMeta, materialID), output);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static ItemStack getPartMapping(Item item, int metadata, int materialID) {
|
2013-12-31 15:30:34 -05:00
|
|
|
ItemStack stack = patternPartMapping.get(Arrays.asList(item, metadata, materialID));
|
2022-09-22 19:51:23 +01:00
|
|
|
if (stack != null) return stack.copy();
|
2013-07-26 21:18:53 -07:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Tools
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Internal tool mapping, used for adding textures
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2013-07-26 21:18:53 -07:00
|
|
|
* @param tool
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addToolMapping(ToolCore tool) {
|
2013-07-26 21:18:53 -07:00
|
|
|
tools.add(tool);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Internal tool mapping, used for adding textures
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2013-07-26 21:18:53 -07:00
|
|
|
* @return List of tools
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static ArrayList<ToolCore> getToolMapping() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return tools;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Registers a tool to its crafting parts. If an output is registered
|
|
|
|
|
* multiple times the parts are added to the recipe's input list Valid part
|
|
|
|
|
* amounts are 2, 3, and 4.
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-08-23 11:28:56 +02:00
|
|
|
* @see ToolBuilder
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param output
|
|
|
|
|
* The ToolCore to craft
|
|
|
|
|
* @param parts
|
|
|
|
|
* Pieces to make the tool with
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addToolRecipe(ToolCore output, Item... parts) {
|
2013-07-26 21:18:53 -07:00
|
|
|
ToolBuilder tb = ToolBuilder.instance;
|
2022-09-22 19:51:23 +01:00
|
|
|
if (parts.length < 2 || parts.length > 4) logger.warn("Wrong amount of items to craft into a tool");
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
tb.addToolRecipe(output, parts);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Materials
|
2014-06-30 22:26:00 -08:00
|
|
|
public static HashMap<Integer, ToolMaterial> toolMaterials = new HashMap<Integer, ToolMaterial>(40);
|
|
|
|
|
public static HashMap<String, ToolMaterial> toolMaterialStrings = new HashMap<String, ToolMaterial>(40);
|
2014-10-15 23:17:41 +02:00
|
|
|
public static List<Integer> defaultToolPartMaterials = new LinkedList<Integer>();
|
2014-10-18 17:02:43 +02:00
|
|
|
public static List<Integer> defaultShardMaterials = new LinkedList<Integer>();
|
2014-10-15 23:17:41 +02:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addDefaultToolPartMaterial(int materialID) {
|
|
|
|
|
if (!toolMaterials.containsKey(materialID))
|
2014-10-15 23:17:41 +02:00
|
|
|
logger.error("[TCon API] Can't add default toolpart: Material ID " + materialID + " is unknown.");
|
2022-09-22 19:51:23 +01:00
|
|
|
else defaultToolPartMaterials.add(materialID);
|
2014-10-15 23:17:41 +02:00
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addDefaultShardMaterial(int materialID) {
|
|
|
|
|
if (!toolMaterials.containsKey(materialID))
|
2014-10-18 17:02:43 +02:00
|
|
|
logger.error("[TCon API] Can't add default shard: Material ID " + materialID + " is unknown.");
|
2022-09-22 19:51:23 +01:00
|
|
|
else defaultShardMaterials.add(materialID);
|
2014-10-18 17:02:43 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Adds a tool material to the registry
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param materialID
|
|
|
|
|
* Unique ID, stored for each part
|
|
|
|
|
* @param materialName
|
|
|
|
|
* Unique name for data lookup purposes
|
|
|
|
|
* @param harvestLevel
|
|
|
|
|
* The materials which the tool can harvest. Pickaxe levels - 0:
|
|
|
|
|
* Wood, 1: Stone, 2: Redstone/Diamond, 3: Obsidian, 4:
|
|
|
|
|
* Cobalt/Ardite, 5: Manyullyn
|
|
|
|
|
* @param durability
|
|
|
|
|
* Base durability of the tool, affects tool heads.
|
|
|
|
|
* @param miningspeed
|
|
|
|
|
* Base mining speed, divided by 100 in use
|
|
|
|
|
* @param attack
|
|
|
|
|
* Base attack
|
|
|
|
|
* @param handleModifier
|
|
|
|
|
* Durability multiplier on the tool
|
|
|
|
|
* @param reinforced
|
|
|
|
|
* Reinforced level
|
|
|
|
|
* @param stonebound
|
|
|
|
|
* Amount of Stonebound to put on the tool. Negative numbers are
|
|
|
|
|
* Spiny.
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addToolMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
String materialName,
|
|
|
|
|
int harvestLevel,
|
|
|
|
|
int durability,
|
|
|
|
|
int miningspeed,
|
|
|
|
|
int attack,
|
|
|
|
|
float handleModifier,
|
|
|
|
|
int reinforced,
|
|
|
|
|
float stonebound,
|
|
|
|
|
String style,
|
|
|
|
|
int primaryColor) {
|
2014-06-30 22:26:00 -08:00
|
|
|
ToolMaterial mat = toolMaterials.get(materialID);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (mat == null) {
|
|
|
|
|
mat = new ToolMaterial(
|
|
|
|
|
materialName,
|
|
|
|
|
harvestLevel,
|
|
|
|
|
durability,
|
|
|
|
|
miningspeed,
|
|
|
|
|
attack,
|
|
|
|
|
handleModifier,
|
|
|
|
|
reinforced,
|
|
|
|
|
stonebound,
|
|
|
|
|
style,
|
|
|
|
|
primaryColor);
|
2013-07-26 21:18:53 -07:00
|
|
|
toolMaterials.put(materialID, mat);
|
|
|
|
|
toolMaterialStrings.put(materialName, mat);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 18:39:06 +02:00
|
|
|
/**
|
|
|
|
|
* Adds a tool material to the registry
|
|
|
|
|
*
|
|
|
|
|
* @param materialID
|
|
|
|
|
* Unique ID, stored for each part
|
|
|
|
|
* @param materialName
|
|
|
|
|
* Unique name for data lookup purposes
|
|
|
|
|
* @param localizationName
|
|
|
|
|
* The string used to localize the material name
|
|
|
|
|
* @param harvestLevel
|
|
|
|
|
* The materials which the tool can harvest. Pickaxe levels - 0:
|
|
|
|
|
* Wood, 1: Stone, 2: Redstone/Diamond, 3: Obsidian, 4:
|
|
|
|
|
* Cobalt/Ardite, 5: Manyullyn
|
|
|
|
|
* @param durability
|
|
|
|
|
* Base durability of the tool, affects tool heads.
|
|
|
|
|
* @param miningspeed
|
|
|
|
|
* Base mining speed, divided by 100 in use
|
|
|
|
|
* @param attack
|
|
|
|
|
* Base attack
|
|
|
|
|
* @param handleModifier
|
|
|
|
|
* Durability multiplier on the tool
|
|
|
|
|
* @param reinforced
|
|
|
|
|
* Reinforced level
|
|
|
|
|
* @param stonebound
|
|
|
|
|
* Amount of Stonebound to put on the tool. Negative numbers are
|
|
|
|
|
* Spiny.
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addToolMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
String materialName,
|
|
|
|
|
String localizationName,
|
|
|
|
|
int harvestLevel,
|
|
|
|
|
int durability,
|
|
|
|
|
int miningspeed,
|
|
|
|
|
int attack,
|
|
|
|
|
float handleModifier,
|
|
|
|
|
int reinforced,
|
|
|
|
|
float stonebound,
|
|
|
|
|
String style,
|
|
|
|
|
int primaryColor) {
|
2014-09-10 18:39:06 +02:00
|
|
|
ToolMaterial mat = toolMaterials.get(materialID);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (mat == null) {
|
|
|
|
|
mat = new ToolMaterial(
|
|
|
|
|
materialName,
|
|
|
|
|
localizationName,
|
|
|
|
|
harvestLevel,
|
|
|
|
|
durability,
|
|
|
|
|
miningspeed,
|
|
|
|
|
attack,
|
|
|
|
|
handleModifier,
|
|
|
|
|
reinforced,
|
|
|
|
|
stonebound,
|
|
|
|
|
style,
|
|
|
|
|
primaryColor);
|
2014-09-10 18:39:06 +02:00
|
|
|
toolMaterials.put(materialID, mat);
|
|
|
|
|
toolMaterialStrings.put(materialName, mat);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
2014-09-10 18:39:06 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-09 19:54:50 +10:00
|
|
|
@Deprecated
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addToolMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
String materialName,
|
|
|
|
|
int harvestLevel,
|
|
|
|
|
int durability,
|
|
|
|
|
int miningspeed,
|
|
|
|
|
int attack,
|
|
|
|
|
float handleModifier,
|
|
|
|
|
int reinforced,
|
|
|
|
|
float stonebound,
|
|
|
|
|
String style) {
|
|
|
|
|
logger.warn(
|
|
|
|
|
"[TCon API] Using deprecated addToolMaterial with no primary color. A fallback of white will be used.");
|
|
|
|
|
addToolMaterial(
|
|
|
|
|
materialID,
|
|
|
|
|
materialName,
|
|
|
|
|
harvestLevel,
|
|
|
|
|
durability,
|
|
|
|
|
miningspeed,
|
|
|
|
|
attack,
|
|
|
|
|
handleModifier,
|
|
|
|
|
reinforced,
|
|
|
|
|
stonebound,
|
|
|
|
|
style,
|
|
|
|
|
0xFFFFFF);
|
2014-09-09 19:54:50 +10:00
|
|
|
}
|
|
|
|
|
|
2014-09-03 14:58:05 +02:00
|
|
|
@Deprecated
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addToolMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
String materialName,
|
|
|
|
|
int harvestLevel,
|
|
|
|
|
int durability,
|
|
|
|
|
int miningspeed,
|
|
|
|
|
int attack,
|
|
|
|
|
float handleModifier,
|
|
|
|
|
int reinforced,
|
|
|
|
|
float stonebound,
|
|
|
|
|
String style,
|
|
|
|
|
String ability) {
|
|
|
|
|
logger.warn(
|
|
|
|
|
"[TCon API] Using deprecated addToolMaterial with ability name. ability will be ignored, use languages files for that.");
|
|
|
|
|
addToolMaterial(
|
|
|
|
|
materialID,
|
|
|
|
|
materialName,
|
|
|
|
|
harvestLevel,
|
|
|
|
|
durability,
|
|
|
|
|
miningspeed,
|
|
|
|
|
attack,
|
|
|
|
|
handleModifier,
|
|
|
|
|
reinforced,
|
|
|
|
|
stonebound,
|
|
|
|
|
style);
|
2014-09-03 14:58:05 +02:00
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-01 22:40:00 +02:00
|
|
|
@Deprecated
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addToolMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
String materialName,
|
|
|
|
|
String displayName,
|
|
|
|
|
int harvestLevel,
|
|
|
|
|
int durability,
|
|
|
|
|
int miningspeed,
|
|
|
|
|
int attack,
|
|
|
|
|
float handleModifier,
|
|
|
|
|
int reinforced,
|
|
|
|
|
float stonebound,
|
|
|
|
|
String style,
|
|
|
|
|
String ability) {
|
|
|
|
|
logger.warn(
|
|
|
|
|
"[TCon API] Using deprecated addToolMaterial with display and ability name. displayName and ability will be ignored, use languages files for that.");
|
|
|
|
|
addToolMaterial(
|
|
|
|
|
materialID,
|
|
|
|
|
materialName,
|
|
|
|
|
harvestLevel,
|
|
|
|
|
durability,
|
|
|
|
|
miningspeed,
|
|
|
|
|
attack,
|
|
|
|
|
handleModifier,
|
|
|
|
|
reinforced,
|
|
|
|
|
stonebound,
|
|
|
|
|
style);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Adds a tool material to the registry
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param materialID
|
|
|
|
|
* Unique ID, stored for each part
|
|
|
|
|
* @param material
|
|
|
|
|
* Complete tool material to add. Uses the name in the material
|
|
|
|
|
* for lookup purposes.
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addtoolMaterial(int materialID, ToolMaterial material) {
|
2014-06-30 22:26:00 -08:00
|
|
|
ToolMaterial mat = toolMaterials.get(materialID);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (mat == null) {
|
2014-07-27 19:58:07 +02:00
|
|
|
toolMaterials.put(materialID, material);
|
|
|
|
|
toolMaterialStrings.put(material.name(), material);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Looks up a tool material by ID
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param key
|
|
|
|
|
* The ID to look up
|
2013-07-26 21:18:53 -07:00
|
|
|
* @return Tool Material
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static ToolMaterial getMaterial(int key) {
|
|
|
|
|
if (toolMaterials.containsKey(key)) {
|
2021-10-03 20:35:19 -06:00
|
|
|
return (toolMaterials.get(key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is probably an old tool whose material has been removed from the game.
|
|
|
|
|
// Fall back to wood.
|
|
|
|
|
return toolMaterials.get(TinkerTools.MaterialID.Wood);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Looks up a tool material by name
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* @param key
|
|
|
|
|
* the name to look up
|
2013-07-26 21:18:53 -07:00
|
|
|
* @return Tool Material
|
|
|
|
|
*/
|
2022-09-22 19:51:23 +01:00
|
|
|
public static ToolMaterial getMaterial(String key) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return (toolMaterialStrings.get(key));
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Bow materials
|
2013-07-26 21:18:53 -07:00
|
|
|
public static HashMap<Integer, BowMaterial> bowMaterials = new HashMap<Integer, BowMaterial>(40);
|
|
|
|
|
|
2014-10-05 22:19:04 +02:00
|
|
|
@Deprecated
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addBowMaterial(int materialID, int durability, int drawSpeed, float speedMax) {
|
2014-10-05 22:19:04 +02:00
|
|
|
addBowMaterial(materialID, drawSpeed, speedMax);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addBowMaterial(int materialID, int drawSpeed, float speedMax) {
|
2013-07-26 21:18:53 -07:00
|
|
|
BowMaterial mat = bowMaterials.get(materialID);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (mat == null) {
|
2014-10-05 22:19:04 +02:00
|
|
|
mat = new BowMaterial(drawSpeed, speedMax);
|
2013-07-26 21:18:53 -07:00
|
|
|
bowMaterials.put(materialID, mat);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else throw new IllegalArgumentException("[TCon API] Bow Material ID " + materialID + " is already occupied");
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static boolean validBowMaterial(int materialID) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return bowMaterials.containsKey(materialID);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static BowMaterial getBowMaterial(int materialID) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return bowMaterials.get(materialID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static HashMap<Integer, ArrowMaterial> arrowMaterials = new HashMap<Integer, ArrowMaterial>(40);
|
|
|
|
|
|
2014-10-05 22:19:04 +02:00
|
|
|
@Deprecated
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addArrowMaterial(int materialID, float mass, float breakChance, float accuracy) {
|
2014-10-16 18:03:34 +02:00
|
|
|
addArrowMaterial(materialID, mass, breakChance);
|
2014-10-05 22:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addArrowMaterial(int materialID, float mass, float breakChance) {
|
2013-07-26 21:18:53 -07:00
|
|
|
ArrowMaterial mat = arrowMaterials.get(materialID);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (mat == null) {
|
2014-10-05 22:19:04 +02:00
|
|
|
mat = new ArrowMaterial(mass, breakChance);
|
2013-07-26 21:18:53 -07:00
|
|
|
arrowMaterials.put(materialID, mat);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else
|
2013-07-26 21:18:53 -07:00
|
|
|
throw new IllegalArgumentException("[TCon API] Arrow Material ID " + materialID + " is already occupied");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static boolean validArrowMaterial(int materialID) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return arrowMaterials.containsKey(materialID);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static ArrowMaterial getArrowMaterial(int materialID) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return arrowMaterials.get(materialID);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Custom materials - bowstrings, fletching, etc
|
2013-07-26 21:18:53 -07:00
|
|
|
public static ArrayList<CustomMaterial> customMaterials = new ArrayList<CustomMaterial>();
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addCustomMaterial(CustomMaterial mat) {
|
|
|
|
|
if (mat != null) customMaterials.add(mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addBowstringMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
int value,
|
|
|
|
|
ItemStack input,
|
|
|
|
|
ItemStack craftingMaterial,
|
|
|
|
|
float durability,
|
|
|
|
|
float drawSpeed,
|
|
|
|
|
float flightSpeed,
|
|
|
|
|
int color) {
|
|
|
|
|
BowstringMaterial mat = new BowstringMaterial(
|
|
|
|
|
materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed, color);
|
2014-09-30 19:40:22 +02:00
|
|
|
customMaterials.add(mat);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addFletchingMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
int value,
|
|
|
|
|
ItemStack input,
|
|
|
|
|
ItemStack craftingMaterial,
|
|
|
|
|
float accuracy,
|
|
|
|
|
float breakChance,
|
|
|
|
|
float durabilityModifier,
|
|
|
|
|
int color) {
|
|
|
|
|
FletchingMaterial mat = new FletchingMaterial(
|
|
|
|
|
materialID, value, input, craftingMaterial, accuracy, breakChance, durabilityModifier, color);
|
2014-09-30 19:40:22 +02:00
|
|
|
customMaterials.add(mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Deprecated
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addBowstringMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
int value,
|
|
|
|
|
ItemStack input,
|
|
|
|
|
ItemStack craftingMaterial,
|
|
|
|
|
float durability,
|
|
|
|
|
float drawSpeed,
|
|
|
|
|
float flightSpeed) {
|
|
|
|
|
BowstringMaterial mat =
|
|
|
|
|
new BowstringMaterial(materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed);
|
2013-07-26 21:18:53 -07:00
|
|
|
customMaterials.add(mat);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-30 19:40:22 +02:00
|
|
|
@Deprecated
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void addFletchingMaterial(
|
|
|
|
|
int materialID,
|
|
|
|
|
int value,
|
|
|
|
|
ItemStack input,
|
|
|
|
|
ItemStack craftingMaterial,
|
|
|
|
|
float accuracy,
|
|
|
|
|
float breakChance,
|
|
|
|
|
float mass) {
|
|
|
|
|
FletchingMaterial mat =
|
|
|
|
|
new FletchingMaterial(materialID, value, input, craftingMaterial, accuracy, breakChance, mass);
|
2013-07-26 21:18:53 -07:00
|
|
|
customMaterials.add(mat);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static CustomMaterial getCustomMaterial(int materialID, Class<? extends CustomMaterial> clazz) {
|
|
|
|
|
for (CustomMaterial mat : customMaterials) {
|
|
|
|
|
if (mat.getClass().equals(clazz) && mat.materialID == materialID) return mat;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static CustomMaterial getCustomMaterial(ItemStack input, Class<? extends CustomMaterial> clazz) {
|
|
|
|
|
for (CustomMaterial mat : customMaterials) {
|
|
|
|
|
if (mat.getClass().equals(clazz) && mat.matches(input)) return mat;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* public static CustomMaterial getCustomMaterial(ItemStack input, ItemStack
|
|
|
|
|
* pattern) { for (CustomMaterial mat : customMaterials) { if
|
|
|
|
|
* (mat.matches(input, pattern)) return mat; } return null; }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* public static ItemStack craftBowString(ItemStack stack) { if
|
|
|
|
|
* (stack.stackSize < 3) return null;
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* for (BowstringMaterial mat : bowstringMaterials) { if
|
|
|
|
|
* (stack.isItemEqual(mat.input)) return mat.craftingItem.copy(); } return
|
|
|
|
|
* null; }
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* public static BowstringMaterial getBowstringMaterial(ItemStack stack) {
|
|
|
|
|
* if (stack.stackSize < 3) return null;
|
2022-09-22 19:51:23 +01:00
|
|
|
*
|
2014-02-16 14:23:50 -05:00
|
|
|
* for (BowstringMaterial mat : bowstringMaterials) { if
|
|
|
|
|
* (stack.isItemEqual(mat.input)) return mat; } return null; }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static LiquidCasting getTableCasting() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return instance.tableCasting();
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
LiquidCasting tableCasting() {
|
|
|
|
|
try {
|
2013-07-26 21:18:53 -07:00
|
|
|
Class clazz = Class.forName("tconstruct.TConstruct");
|
|
|
|
|
Method method = clazz.getMethod("getTableCasting");
|
|
|
|
|
LiquidCasting lc = (LiquidCasting) method.invoke(this);
|
|
|
|
|
return lc;
|
2022-09-22 19:51:23 +01:00
|
|
|
} catch (Exception e) {
|
2014-02-20 14:20:02 -05:00
|
|
|
logger.warn("Could not find casting table recipes.");
|
2013-07-26 21:18:53 -07:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static LiquidCasting getBasinCasting() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return instance.basinCasting();
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
LiquidCasting basinCasting() {
|
|
|
|
|
try {
|
2013-07-26 21:18:53 -07:00
|
|
|
Class clazz = Class.forName("tconstruct.TConstruct");
|
|
|
|
|
Method method = clazz.getMethod("getBasinCasting");
|
|
|
|
|
LiquidCasting lc = (LiquidCasting) method.invoke(this);
|
|
|
|
|
return lc;
|
2022-09-22 19:51:23 +01:00
|
|
|
} catch (Exception e) {
|
2014-02-20 14:20:02 -05:00
|
|
|
logger.warn("Could not find casting basin recipes.");
|
2013-07-26 21:18:53 -07:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static Detailing getChiselDetailing() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return instance.chiselDetailing();
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
Detailing chiselDetailing() {
|
|
|
|
|
try {
|
2013-07-26 21:18:53 -07:00
|
|
|
Class clazz = Class.forName("tconstruct.TConstruct");
|
|
|
|
|
Method method = clazz.getMethod("getChiselDetailing");
|
|
|
|
|
Detailing lc = (Detailing) method.invoke(this);
|
|
|
|
|
return lc;
|
2022-09-22 19:51:23 +01:00
|
|
|
} catch (Exception e) {
|
2014-02-20 14:20:02 -05:00
|
|
|
logger.warn("Could not find chisel detailing recipes.");
|
2013-07-26 21:18:53 -07:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ArrayList<ActiveToolMod> activeModifiers = new ArrayList<ActiveToolMod>();
|
2014-06-30 22:26:00 -08:00
|
|
|
public static LinkedList<ActiveArmorMod> activeArmorModifiers = new LinkedList<ActiveArmorMod>();
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void registerActiveToolMod(ActiveToolMod mod) {
|
2013-07-26 21:18:53 -07:00
|
|
|
activeModifiers.add(mod);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static void registerActiveArmorMod(ActiveArmorMod mod) {
|
2014-06-30 22:26:00 -08:00
|
|
|
activeArmorModifiers.add(mod);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/**
|
|
|
|
|
* Default Material Index 0: Wood 1: Stone 2: Iron 3: Flint 4: Cactus 5:
|
|
|
|
|
* Bone 6: Obsidian 7: Netherrack 8: Green Slime 9: Paper 10: Cobalt 11:
|
|
|
|
|
* Ardite 12: Manyullyn 13: Copper 14: Bronze 15: Alumite 16: Steel 17: Blue
|
|
|
|
|
* Slime
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
|
|
|
|
}
|