use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class GTJeiPlugin method register.
@Override
public void register(IModRegistry registry) {
IJeiHelpers jeiHelpers = registry.getJeiHelpers();
registry.addRecipes(IntCircuitRecipeWrapper.create(), IntCircuitCategory.UID);
MultiblockInfoCategory.registerRecipes(registry);
registry.handleRecipes(CustomItemReturnShapedOreRecipeRecipe.class, recipe -> new CustomItemReturnRecipeWrapper(jeiHelpers, recipe), VanillaRecipeCategoryUid.CRAFTING);
registry.addRecipeRegistryPlugin(new FacadeRegistryPlugin());
// register transfer handler for all categories, but not for the crafting station
ModularUIGuiHandler modularUIGuiHandler = new ModularUIGuiHandler(jeiHelpers.recipeTransferHandlerHelper());
modularUIGuiHandler.setValidHandlers(widget -> !(widget instanceof CraftingSlotWidget));
registry.getRecipeTransferRegistry().addRecipeTransferHandler(modularUIGuiHandler, Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
registry.addAdvancedGuiHandlers(modularUIGuiHandler);
registry.addGhostIngredientHandler(modularUIGuiHandler.getGuiContainerClass(), modularUIGuiHandler);
// register transfer handler for crafting recipes
ModularUIGuiHandler craftingStationGuiHandler = new ModularUIGuiHandler(jeiHelpers.recipeTransferHandlerHelper());
registry.getRecipeTransferRegistry().addRecipeTransferHandler(craftingStationGuiHandler, VanillaRecipeCategoryUid.CRAFTING);
for (RecipeMap<?> recipeMap : RecipeMap.getRecipeMaps()) {
if (!recipeMap.isHidden) {
Stream<Recipe> recipeStream = recipeMap.getRecipeList().stream().filter(recipe -> !recipe.isHidden() && recipe.hasValidInputsForDisplay());
if (recipeMap.getSmallRecipeMap() != null) {
Collection<Recipe> smallRecipes = recipeMap.getSmallRecipeMap().getRecipeList();
recipeStream = recipeStream.filter(recipe -> !smallRecipes.contains(recipe));
}
registry.addRecipes(recipeStream.map(r -> new GTRecipeWrapper(recipeMap, r)).collect(Collectors.toList()), GTValues.MODID + ":" + recipeMap.unlocalizedName);
}
}
for (ResourceLocation metaTileEntityId : GregTechAPI.MTE_REGISTRY.getKeys()) {
MetaTileEntity metaTileEntity = GregTechAPI.MTE_REGISTRY.getObject(metaTileEntityId);
assert metaTileEntity != null;
if (metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null) != null) {
IControllable workableCapability = metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null);
if (workableCapability instanceof AbstractRecipeLogic) {
AbstractRecipeLogic logic = (AbstractRecipeLogic) workableCapability;
if (metaTileEntity instanceof IMultipleRecipeMaps) {
for (RecipeMap<?> recipeMap : ((IMultipleRecipeMaps) metaTileEntity).getAvailableRecipeMaps()) {
registerRecipeMapCatalyst(registry, recipeMap, metaTileEntity);
}
} else if (logic.getRecipeMap() != null) {
registerRecipeMapCatalyst(registry, logic.getRecipeMap(), metaTileEntity);
}
}
}
}
String semiFluidMapId = GTValues.MODID + ":" + RecipeMaps.SEMI_FLUID_GENERATOR_FUELS.getUnlocalizedName();
registry.addRecipeCatalyst(MetaTileEntities.LARGE_BRONZE_BOILER.getStackForm(), semiFluidMapId);
registry.addRecipeCatalyst(MetaTileEntities.LARGE_STEEL_BOILER.getStackForm(), semiFluidMapId);
registry.addRecipeCatalyst(MetaTileEntities.LARGE_TITANIUM_BOILER.getStackForm(), semiFluidMapId);
registry.addRecipeCatalyst(MetaTileEntities.LARGE_TUNGSTENSTEEL_BOILER.getStackForm(), semiFluidMapId);
List<OreByProduct> oreByproductList = new CopyOnWriteArrayList<>();
for (Material material : GregTechAPI.MATERIAL_REGISTRY) {
if (material.hasProperty(PropertyKey.ORE)) {
oreByproductList.add(new OreByProduct(material));
}
}
String oreByProductId = GTValues.MODID + ":" + "ore_by_product";
registry.addRecipes(oreByproductList, oreByProductId);
MetaTileEntity[][] machineLists = new MetaTileEntity[][] { MetaTileEntities.MACERATOR, MetaTileEntities.ORE_WASHER, MetaTileEntities.CENTRIFUGE, MetaTileEntities.THERMAL_CENTRIFUGE, MetaTileEntities.CHEMICAL_BATH, MetaTileEntities.ELECTROMAGNETIC_SEPARATOR, MetaTileEntities.SIFTER };
for (MetaTileEntity[] machine : machineLists) {
if (machine.length < GTValues.LV + 1 || machine[GTValues.LV] == null)
continue;
registry.addRecipeCatalyst(machine[GTValues.LV].getStackForm(), oreByProductId);
}
// Material Tree
List<MaterialTree> materialTreeList = new CopyOnWriteArrayList<>();
for (Material material : GregTechAPI.MATERIAL_REGISTRY) {
if (material.hasProperty(PropertyKey.DUST)) {
materialTreeList.add(new MaterialTree(material));
}
}
registry.addRecipes(materialTreeList, GTValues.MODID + ":" + "material_tree");
// Ore Veins
List<OreDepositDefinition> oreVeins = WorldGenRegistry.getOreDeposits();
List<GTOreInfo> oreInfoList = new CopyOnWriteArrayList<>();
for (OreDepositDefinition vein : oreVeins) {
oreInfoList.add(new GTOreInfo(vein));
}
String oreSpawnID = GTValues.MODID + ":" + "ore_spawn_location";
registry.addRecipes(oreInfoList, oreSpawnID);
registry.addRecipeCatalyst(MetaItems.PROSPECTOR_LV.getStackForm(), oreSpawnID);
registry.addRecipeCatalyst(MetaItems.PROSPECTOR_HV.getStackForm(), oreSpawnID);
registry.addRecipeCatalyst(MetaItems.PROSPECTOR_LUV.getStackForm(), oreSpawnID);
// Ore Veins End
ingredientRegistry = registry.getIngredientRegistry();
for (int i = 0; i <= IntCircuitIngredient.CIRCUIT_MAX; i++) {
registry.addIngredientInfo(IntCircuitIngredient.getIntegratedCircuit(i), VanillaTypes.ITEM, "metaitem.circuit.integrated.jei_description");
}
registry.addRecipeCatalyst(MetaTileEntities.WORKBENCH.getStackForm(), VanillaRecipeCategoryUid.CRAFTING);
for (MetaTileEntity machine : MetaTileEntities.CANNER) {
if (machine == null)
continue;
registry.addIngredientInfo(machine.getStackForm(), VanillaTypes.ITEM, "gregtech.machine.canner.jei_description");
}
// Multiblock info page registration
MultiblockInfoCategory.REGISTER.forEach(mte -> {
String[] desc = mte.getDescription();
if (desc.length > 0) {
registry.addIngredientInfo(mte.getStackForm(), VanillaTypes.ITEM, mte.getDescription());
}
});
}
Aggregations