use of com.codetaylor.mc.artisanworktables.modules.tools.item.ItemWorktableTool in project artisan-worktables by codetaylor.
the class ModuleToolsRecipes method register.
/**
* Iterates through all given items in the tool list and registers a recipe for each.
*
* @param registry the recipe registry
* @param modId the mod id
* @param toolList the tool list
*/
public static void register(IForgeRegistry<IRecipe> registry, String modId, List<ItemWorktableTool> toolList) {
for (ItemWorktableTool item : toolList) {
Object[] recipeDefinition = ModuleToolsRecipes.getRecipeDefinition(item.getType(), item.getMaterial().getIngredient());
if (recipeDefinition == null) {
throw new RuntimeException("Missing recipe definition for tool type: " + item.getType().getName());
}
ShapedOreRecipe recipe = new ShapedOreRecipe(null, item, recipeDefinition);
recipe.setRegistryName(new ResourceLocation(modId, "recipe." + item.getName() + "." + item.getMaterial().getDataCustomMaterial().getName()));
registry.register(recipe);
}
}
use of com.codetaylor.mc.artisanworktables.modules.tools.item.ItemWorktableTool in project artisan-worktables by codetaylor.
the class ModuleTools method onRegister.
@Override
public void onRegister(Registry registry) {
super.onRegister(registry);
List<String> allowedToolTypeList = new ArrayList<>(Arrays.asList(ModuleToolsConfig.ENABLED_TOOL_TYPES));
if (allowedToolTypeList.isEmpty()) {
// User has disabled all tool types.
return;
}
if (this.materialList.isEmpty()) {
// User has disabled all tool materials.
return;
}
for (EnumWorktableToolType type : EnumWorktableToolType.values()) {
String typeName = type.getName();
if (!allowedToolTypeList.contains(typeName)) {
// User has disabled this tool type.
continue;
}
for (CustomMaterial material : this.materialList) {
String materialName = material.getDataCustomMaterial().getName();
ItemWorktableToolBase item = new ItemWorktableTool(type, material);
this.registerTool(registry, typeName, materialName, item);
}
ArtisanCustomToolMaterialRegistrationEvent event = new ArtisanCustomToolMaterialRegistrationEvent();
MinecraftForge.EVENT_BUS.post(event);
List<CustomToolMaterialRegistrationEntry> materialList = event.getMaterialList();
CustomMaterialConverter customMaterialConverter = new CustomMaterialConverter(RecipeItemParser.INSTANCE);
for (CustomToolMaterialRegistrationEntry entry : materialList) {
try {
ICustomToolMaterial material = entry.getMaterial();
ICustomToolProvider provider = entry.getProvider();
CustomMaterial customMaterial = customMaterialConverter.convert(material);
ItemWorktableToolBase item = provider.get(type, customMaterial);
String materialName = customMaterial.getDataCustomMaterial().getName();
this.registerTool(registry, typeName, materialName, item);
} catch (MalformedRecipeItemException e) {
ModuleTools.LOGGER.error("", e);
}
}
}
registry.registerItemRegistrationStrategy(forgeRegistry -> {
if (ModuleToolsConfig.ENABLE_TOOL_TYPE_ORE_DICT_GROUPS) {
for (ItemWorktableToolBase item : this.registeredToolList) {
ItemStack itemStack = new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE);
OreDictionary.registerOre(ModuleToolsConfig.TOOL_BY_TYPE_ORE_DICT_PREFIX + item.getType().getOreDictSuffix(), itemStack);
}
}
if (ModuleToolsConfig.ENABLE_TOOL_MATERIAL_ORE_DICT_GROUPS) {
for (ItemWorktableToolBase item : this.registeredToolList) {
ItemStack itemStack = new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE);
OreDictionary.registerOre(item.getMaterial().getDataCustomMaterial().getOreDictKey(), itemStack);
}
}
});
}
Aggregations