Search in sources :

Example 1 with TileCrafter

use of com.lothrazar.cyclic.block.crafter.TileCrafter in project Polymorph by TheIllusiveC4.

the class CyclicModule method selectRecipe.

@SuppressWarnings("ConstantConditions")
@Override
public boolean selectRecipe(BlockEntity tileEntity, Recipe<?> recipe) {
    if (tileEntity instanceof TileCrafter) {
        AccessorTileCrafter tileCrafter = (AccessorTileCrafter) tileEntity;
        tileCrafter.setLastValidRecipe(recipe);
        tileCrafter.setRecipeOutput(recipe.getResultItem());
        LazyOptional<IItemHandler> preview = tileCrafter.getPreview();
        if (preview != null) {
            tileCrafter.callSetPreviewSlot(preview.orElse(null), recipe.getResultItem());
        }
        return true;
    }
    return false;
}
Also used : AccessorTileCrafter(top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorTileCrafter) IItemHandler(net.minecraftforge.items.IItemHandler) AccessorTileCrafter(top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorTileCrafter) TileCrafter(com.lothrazar.cyclic.block.crafter.TileCrafter)

Example 2 with TileCrafter

use of com.lothrazar.cyclic.block.crafter.TileCrafter in project Polymorph by TheIllusiveC4.

the class CyclicModule method setup.

@Override
public void setup() {
    IPolymorphCommon commonApi = PolymorphApi.common();
    commonApi.registerTileEntity2RecipeData(tileEntity -> {
        if (tileEntity instanceof TileCrafter) {
            return new TileCrafterRecipeData((TileCrafter) tileEntity);
        }
        return null;
    });
    commonApi.registerContainer2TileEntity(container -> {
        if (container instanceof ContainerCrafter) {
            return ((AccessorContainerCrafter) container).getTile();
        }
        return null;
    });
}
Also used : ContainerCrafter(com.lothrazar.cyclic.block.crafter.ContainerCrafter) AccessorContainerCrafter(top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorContainerCrafter) AccessorContainerCrafter(top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorContainerCrafter) IPolymorphCommon(top.theillusivec4.polymorph.api.common.base.IPolymorphCommon) AccessorTileCrafter(top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorTileCrafter) TileCrafter(com.lothrazar.cyclic.block.crafter.TileCrafter)

Aggregations

TileCrafter (com.lothrazar.cyclic.block.crafter.TileCrafter)2 AccessorTileCrafter (top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorTileCrafter)2 ContainerCrafter (com.lothrazar.cyclic.block.crafter.ContainerCrafter)1 IItemHandler (net.minecraftforge.items.IItemHandler)1 IPolymorphCommon (top.theillusivec4.polymorph.api.common.base.IPolymorphCommon)1 AccessorContainerCrafter (top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorContainerCrafter)1