use of gregtech.common.gui.widget.craftingstation.CraftingSlotWidget in project GregTech by GregTechCEu.
the class MetaTileEntityWorkbench method createWorkbenchTab.
public static AbstractWidgetGroup createWorkbenchTab(CraftingRecipeLogic craftingRecipeLogic, ItemStackHandler craftingGrid, CraftingRecipeMemory recipeMemory, ItemStackHandler toolInventory, ItemStackHandler internalInventory) {
WidgetGroup widgetGroup = new WidgetGroup();
widgetGroup.addWidget(new ImageWidget(88 - 13, 44 - 14, 26, 26, GuiTextures.SLOT));
widgetGroup.addWidget(new CraftingSlotWidget(craftingRecipeLogic, 0, 88 - 9, 44 - 9));
// crafting grid
widgetGroup.addWidget(new CraftingStationInputWidgetGroup(4, 7, craftingGrid, craftingRecipeLogic));
Supplier<String> textSupplier = () -> Integer.toString(craftingRecipeLogic.getItemsCraftedAmount());
widgetGroup.addWidget(new SimpleTextWidget(88, 44 + 19, "", textSupplier));
Consumer<ClickData> clearAction = (clickData) -> craftingRecipeLogic.clearCraftingGrid();
widgetGroup.addWidget(new ClickButtonWidget(8 + 18 * 3 + 3, 16, 8, 8, "", clearAction).setButtonTexture(GuiTextures.BUTTON_CLEAR_GRID));
widgetGroup.addWidget(new ImageWidget(168 - 18 * 3, 44 - 19 * 3 / 2, 18 * 3, 18 * 3, TextureArea.fullImage("textures/gui/base/darkened_slot.png")));
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
widgetGroup.addWidget(new MemorizedRecipeWidget(recipeMemory, j + i * 3, craftingGrid, 168 - 18 * 3 / 2 - 27 + j * 18, 44 - 28 + i * 18));
}
}
// tool inventory
for (int i = 0; i < 9; i++) {
widgetGroup.addWidget(new SlotWidget(toolInventory, i, 7 + i * 18, 75).setBackgroundTexture(GuiTextures.SLOT, GuiTextures.TOOL_SLOT_OVERLAY));
}
// internal inventory
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 9; ++j) {
widgetGroup.addWidget(new SlotWidget(internalInventory, j + i * 9, 7 + j * 18, 98 + i * 18).setBackgroundTexture(GuiTextures.SLOT));
}
}
return widgetGroup;
}
use of gregtech.common.gui.widget.craftingstation.CraftingSlotWidget 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