Search in sources :

Example 6 with TraceabilityPredicate

use of gregtech.api.pattern.TraceabilityPredicate in project GregTech by GregTechCEu.

the class MultiblockInfoRecipeWrapper method handleClick.

@Override
public boolean handleClick(@Nonnull Minecraft minecraft, int mouseX, int mouseY, int mouseButton) {
    for (Entry<GuiButton, Runnable> button : buttons.entrySet()) {
        if (button.getKey().mousePressed(minecraft, mouseX, mouseY)) {
            button.getValue().run();
            selected = null;
            return true;
        }
    }
    if (mouseButton == 1) {
        if (getCurrentRenderer().getLastTraceResult() == null) {
            if (this.selected != null) {
                this.selected = null;
                for (int i = 0; i < predicates.size(); i++) {
                    recipeLayout.getItemStacks().set(i + MAX_PARTS, ItemStack.EMPTY);
                }
                predicates.clear();
                this.father = null;
                return true;
            }
            return false;
        }
        BlockPos selected = getCurrentRenderer().getLastTraceResult().getBlockPos();
        if (!Objects.equals(this.selected, selected)) {
            for (int i = 0; i < predicates.size(); i++) {
                recipeLayout.getItemStacks().set(i + MAX_PARTS, ItemStack.EMPTY);
            }
            predicates.clear();
            this.father = null;
            this.selected = selected;
            TraceabilityPredicate predicate = patterns[currentRendererPage].predicateMap.get(this.selected);
            if (predicate != null) {
                predicates.addAll(predicate.common);
                predicates.addAll(predicate.limited);
                predicates.removeIf(p -> p.candidates == null);
                this.father = predicate;
                setItemStackGroup();
            }
            return true;
        }
    }
    return false;
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) BlockPos(net.minecraft.util.math.BlockPos) TraceabilityPredicate(gregtech.api.pattern.TraceabilityPredicate)

Aggregations

TraceabilityPredicate (gregtech.api.pattern.TraceabilityPredicate)6 GuiButton (net.minecraft.client.gui.GuiButton)3 BlockWorldState (gregtech.api.pattern.BlockWorldState)2 PatternMatchContext (gregtech.api.pattern.PatternMatchContext)2 ImmediateWorldSceneRenderer (gregtech.client.renderer.scene.ImmediateWorldSceneRenderer)2 WorldSceneRenderer (gregtech.client.renderer.scene.WorldSceneRenderer)2 IBlockState (net.minecraft.block.state.IBlockState)2 BlockRenderer (codechicken.lib.render.BlockRenderer)1 CCRenderState (codechicken.lib.render.CCRenderState)1 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Translation (codechicken.lib.vec.Translation)1 GuiTextures (gregtech.api.gui.GuiTextures)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)1 MultiblockControllerBase (gregtech.api.metatileentity.multiblock.MultiblockControllerBase)1 MultiblockShapeInfo (gregtech.api.pattern.MultiblockShapeInfo)1 BlockInfo (gregtech.api.util.BlockInfo)1 ItemStackKey (gregtech.api.util.ItemStackKey)1 RenderUtil (gregtech.client.utils.RenderUtil)1