Search in sources :

Example 1 with CraftingSlotWidget

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;
}
Also used : Matrix4(codechicken.lib.vec.Matrix4) Textures(gregtech.client.renderer.texture.Textures) Blocks(net.minecraft.init.Blocks) IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) MemorizedRecipeWidget(gregtech.common.gui.widget.craftingstation.MemorizedRecipeWidget) ArrayUtils(org.apache.commons.lang3.ArrayUtils) IItemList(gregtech.common.inventory.IItemList) ToolItemStackHandler(gregtech.common.inventory.handlers.ToolItemStackHandler) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) gregtech.api.gui.widgets(gregtech.api.gui.widgets) ItemTabInfo(gregtech.api.gui.widgets.tab.ItemTabInfo) Pair(org.apache.commons.lang3.tuple.Pair) ClickData(gregtech.api.gui.Widget.ClickData) NonNullList(net.minecraft.util.NonNullList) ItemSources(gregtech.common.inventory.itemsource.ItemSources) MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) TabLocation(gregtech.api.gui.widgets.TabGroup.TabLocation) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) ItemListGridWidget(gregtech.common.gui.widget.craftingstation.ItemListGridWidget) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CCRenderState(codechicken.lib.render.CCRenderState) GuiTextures(gregtech.api.gui.GuiTextures) Consumer(java.util.function.Consumer) Position(gregtech.api.util.Position) TextureArea(gregtech.api.gui.resources.TextureArea) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) Preconditions(com.google.common.base.Preconditions) ModularUI(gregtech.api.gui.ModularUI) InventoryItemSource(gregtech.common.inventory.itemsource.sources.InventoryItemSource) Builder(gregtech.api.gui.ModularUI.Builder) GTUtility(gregtech.api.util.GTUtility) CraftingSlotWidget(gregtech.common.gui.widget.craftingstation.CraftingSlotWidget) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier) ICraftingStorage(gregtech.api.storage.ICraftingStorage) MemorizedRecipeWidget(gregtech.common.gui.widget.craftingstation.MemorizedRecipeWidget) CraftingSlotWidget(gregtech.common.gui.widget.craftingstation.CraftingSlotWidget) CraftingSlotWidget(gregtech.common.gui.widget.craftingstation.CraftingSlotWidget) ClickData(gregtech.api.gui.Widget.ClickData)

Example 2 with CraftingSlotWidget

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());
        }
    });
}
Also used : OreByProductCategory(gregtech.integration.jei.recipe.primitive.OreByProductCategory) gregtech.integration.jei.utils(gregtech.integration.jei.utils) Item(net.minecraft.item.Item) MetaTileEntities(gregtech.common.metatileentities.MetaTileEntities) IRecipeCategoryRegistration(mezz.jei.api.recipe.IRecipeCategoryRegistration) ObfuscationReflectionHelper(net.minecraftforge.fml.common.ObfuscationReflectionHelper) MetaItem(gregtech.api.items.metaitem.MetaItem) gregtech.integration.jei.recipe(gregtech.integration.jei.recipe) MultiblockInfoCategory(gregtech.integration.jei.multiblock.MultiblockInfoCategory) MaterialTreeCategory(gregtech.integration.jei.recipe.primitive.MaterialTreeCategory) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) Recipe(gregtech.api.recipes.Recipe) OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) WorldGenRegistry(gregtech.api.worldgen.config.WorldGenRegistry) Collection(java.util.Collection) PropertyKey(gregtech.api.unification.material.properties.PropertyKey) Collectors(java.util.stream.Collectors) IIngredientRegistry(mezz.jei.api.ingredients.IIngredientRegistry) Internal(mezz.jei.Internal) List(java.util.List) Stream(java.util.stream.Stream) VanillaRecipeCategoryUid(mezz.jei.api.recipe.VanillaRecipeCategoryUid) IntCircuitIngredient(gregtech.api.recipes.ingredients.IntCircuitIngredient) Constants(mezz.jei.config.Constants) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MetaBlocks(gregtech.common.blocks.MetaBlocks) MetaItems(gregtech.common.items.MetaItems) IMultipleRecipeMaps(gregtech.api.capability.IMultipleRecipeMaps) RecipeMapFurnace(gregtech.api.recipes.machines.RecipeMapFurnace) GregtechTileCapabilities(gregtech.api.capability.GregtechTileCapabilities) GregTechAPI(gregtech.api.GregTechAPI) OreByProduct(gregtech.integration.jei.recipe.primitive.OreByProduct) mezz.jei.api(mezz.jei.api) Material(gregtech.api.unification.material.Material) RecipeMap(gregtech.api.recipes.RecipeMap) RecipeMaps(gregtech.api.recipes.RecipeMaps) Nonnull(javax.annotation.Nonnull) AbstractRecipeLogic(gregtech.api.capability.impl.AbstractRecipeLogic) IShowsRecipeFocuses(mezz.jei.input.IShowsRecipeFocuses) MaterialTree(gregtech.integration.jei.recipe.primitive.MaterialTree) InputHandler(mezz.jei.input.InputHandler) IControllable(gregtech.api.capability.IControllable) SteamMetaTileEntity(gregtech.api.metatileentity.SteamMetaTileEntity) CustomItemReturnShapedOreRecipeRecipe(gregtech.loaders.recipe.CustomItemReturnShapedOreRecipeRecipe) Field(java.lang.reflect.Field) GTValues(gregtech.api.GTValues) ResourceLocation(net.minecraft.util.ResourceLocation) VanillaTypes(mezz.jei.api.ingredients.VanillaTypes) CraftingSlotWidget(gregtech.common.gui.widget.craftingstation.CraftingSlotWidget) Recipe(gregtech.api.recipes.Recipe) CustomItemReturnShapedOreRecipeRecipe(gregtech.loaders.recipe.CustomItemReturnShapedOreRecipeRecipe) OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) OreByProduct(gregtech.integration.jei.recipe.primitive.OreByProduct) CraftingSlotWidget(gregtech.common.gui.widget.craftingstation.CraftingSlotWidget) ResourceLocation(net.minecraft.util.ResourceLocation) AbstractRecipeLogic(gregtech.api.capability.impl.AbstractRecipeLogic) IControllable(gregtech.api.capability.IControllable) Material(gregtech.api.unification.material.Material) MaterialTree(gregtech.integration.jei.recipe.primitive.MaterialTree) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) SteamMetaTileEntity(gregtech.api.metatileentity.SteamMetaTileEntity) IMultipleRecipeMaps(gregtech.api.capability.IMultipleRecipeMaps) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)2 CraftingSlotWidget (gregtech.common.gui.widget.craftingstation.CraftingSlotWidget)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 CCRenderState (codechicken.lib.render.CCRenderState)1 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)1 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)1 Matrix4 (codechicken.lib.vec.Matrix4)1 Preconditions (com.google.common.base.Preconditions)1 GTValues (gregtech.api.GTValues)1 GregTechAPI (gregtech.api.GregTechAPI)1 GregtechTileCapabilities (gregtech.api.capability.GregtechTileCapabilities)1 IControllable (gregtech.api.capability.IControllable)1 IMultipleRecipeMaps (gregtech.api.capability.IMultipleRecipeMaps)1 AbstractRecipeLogic (gregtech.api.capability.impl.AbstractRecipeLogic)1 GuiTextures (gregtech.api.gui.GuiTextures)1 ModularUI (gregtech.api.gui.ModularUI)1 Builder (gregtech.api.gui.ModularUI.Builder)1 ClickData (gregtech.api.gui.Widget.ClickData)1 TextureArea (gregtech.api.gui.resources.TextureArea)1 gregtech.api.gui.widgets (gregtech.api.gui.widgets)1