Search in sources :

Example 1 with IPolymorphCommon

use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.

the class PlayerRecipesWidget method selectRecipe.

@Override
public void selectRecipe(ResourceLocation pResourceLocation) {
    IPolymorphCommon commonApi = PolymorphApi.common();
    Player player = Minecraft.getInstance().player;
    if (player != null) {
        player.level.getRecipeManager().byKey(pResourceLocation).ifPresent(recipe -> commonApi.getRecipeData(player).ifPresent(recipeData -> recipeData.selectRecipe(recipe)));
    }
    commonApi.getPacketDistributor().sendPlayerRecipeSelectionC2S(pResourceLocation);
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) Slot(net.minecraft.world.inventory.Slot) AbstractRecipesWidget(top.theillusivec4.polymorph.api.client.widget.AbstractRecipesWidget) Minecraft(net.minecraft.client.Minecraft) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) PolymorphApi(top.theillusivec4.polymorph.api.PolymorphApi) IPolymorphCommon(top.theillusivec4.polymorph.api.common.base.IPolymorphCommon) Player(net.minecraft.world.entity.player.Player) Player(net.minecraft.world.entity.player.Player) IPolymorphCommon(top.theillusivec4.polymorph.api.common.base.IPolymorphCommon)

Example 2 with IPolymorphCommon

use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.

the class IronFurnacesModule method setup.

@Override
public void setup() {
    IPolymorphCommon commonApi = PolymorphApi.common();
    commonApi.registerTileEntity2RecipeData(pTileEntity -> {
        if (pTileEntity instanceof BlockIronFurnaceTileBase) {
            return new IronFurnaceRecipeData((BlockIronFurnaceTileBase) pTileEntity);
        }
        return null;
    });
}
Also used : IPolymorphCommon(top.theillusivec4.polymorph.api.common.base.IPolymorphCommon) BlockIronFurnaceTileBase(ironfurnaces.tileentity.BlockIronFurnaceTileBase)

Example 3 with IPolymorphCommon

use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.

the class TomsStorageModule method setup.

@Override
public void setup() {
    IPolymorphCommon commonApi = PolymorphApi.common();
    commonApi.registerTileEntity2RecipeData(pTileEntity -> {
        if (pTileEntity instanceof TileEntityCraftingTerminal) {
            return new CraftingTerminalRecipeData((TileEntityCraftingTerminal) pTileEntity);
        }
        return null;
    });
    commonApi.registerContainer2TileEntity(pContainer -> {
        if (pContainer instanceof ContainerCraftingTerminal) {
            return ((AccessorContainerStorageTerminal) pContainer).getTe();
        }
        return null;
    });
}
Also used : AccessorTileEntityCraftingTerminal(top.theillusivec4.polymorph.mixin.integration.toms_storage.AccessorTileEntityCraftingTerminal) TileEntityCraftingTerminal(com.tom.storagemod.tile.TileEntityCraftingTerminal) ContainerCraftingTerminal(com.tom.storagemod.gui.ContainerCraftingTerminal) AccessorContainerStorageTerminal(top.theillusivec4.polymorph.mixin.integration.toms_storage.AccessorContainerStorageTerminal) IPolymorphCommon(top.theillusivec4.polymorph.api.common.base.IPolymorphCommon)

Example 4 with IPolymorphCommon

use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.

the class PolymorphMod method setup.

private void setup(final FMLCommonSetupEvent pEvent) {
    PolymorphNetwork.setup();
    MinecraftForge.EVENT_BUS.register(new CommonEventsListener());
    IPolymorphCommon commonApi = PolymorphApi.common();
    commonApi.registerTileEntity2RecipeData(tileEntity -> {
        if (tileEntity instanceof AbstractFurnaceBlockEntity) {
            return new FurnaceRecipeData((AbstractFurnaceBlockEntity) tileEntity);
        }
        return null;
    });
    commonApi.registerContainer2TileEntity(container -> {
        for (Slot inventorySlot : container.slots) {
            Container inventory = inventorySlot.container;
            if (inventory instanceof BlockEntity) {
                return (BlockEntity) inventory;
            }
        }
        return null;
    });
    PolymorphIntegrations.setup();
}
Also used : Container(net.minecraft.world.Container) AbstractFurnaceBlockEntity(net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity) FurnaceRecipeData(top.theillusivec4.polymorph.common.capability.FurnaceRecipeData) Slot(net.minecraft.world.inventory.Slot) IPolymorphCommon(top.theillusivec4.polymorph.api.common.base.IPolymorphCommon) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) AbstractFurnaceBlockEntity(net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity)

Example 5 with IPolymorphCommon

use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.

the class StackRecipeData method getListeners.

@Override
public Set<ServerPlayer> getListeners() {
    Set<ServerPlayer> players = new HashSet<>();
    IPolymorphCommon commonApi = PolymorphApi.common();
    commonApi.getServer().ifPresent(server -> {
        for (ServerPlayer player : server.getPlayerList().getPlayers()) {
            commonApi.getRecipeDataFromItemStack(player.containerMenu).ifPresent(recipeData -> {
                if (recipeData == this) {
                    players.add(player);
                }
            });
        }
    });
    return players;
}
Also used : ServerPlayer(net.minecraft.server.level.ServerPlayer) IPolymorphCommon(top.theillusivec4.polymorph.api.common.base.IPolymorphCommon) HashSet(java.util.HashSet)

Aggregations

IPolymorphCommon (top.theillusivec4.polymorph.api.common.base.IPolymorphCommon)6 Slot (net.minecraft.world.inventory.Slot)2 ContainerCrafter (com.lothrazar.cyclic.block.crafter.ContainerCrafter)1 TileCrafter (com.lothrazar.cyclic.block.crafter.TileCrafter)1 ContainerCraftingTerminal (com.tom.storagemod.gui.ContainerCraftingTerminal)1 TileEntityCraftingTerminal (com.tom.storagemod.tile.TileEntityCraftingTerminal)1 BlockIronFurnaceTileBase (ironfurnaces.tileentity.BlockIronFurnaceTileBase)1 HashSet (java.util.HashSet)1 Minecraft (net.minecraft.client.Minecraft)1 AbstractContainerScreen (net.minecraft.client.gui.screens.inventory.AbstractContainerScreen)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 ServerPlayer (net.minecraft.server.level.ServerPlayer)1 Container (net.minecraft.world.Container)1 Player (net.minecraft.world.entity.player.Player)1 AbstractFurnaceBlockEntity (net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1 PolymorphApi (top.theillusivec4.polymorph.api.PolymorphApi)1 AbstractRecipesWidget (top.theillusivec4.polymorph.api.client.widget.AbstractRecipesWidget)1 FurnaceRecipeData (top.theillusivec4.polymorph.common.capability.FurnaceRecipeData)1 AccessorContainerCrafter (top.theillusivec4.polymorph.mixin.integration.cyclic.AccessorContainerCrafter)1