Search in sources :

Example 1 with ItemCombinerMenu

use of net.minecraft.world.inventory.ItemCombinerMenu in project Polymorph by TheIllusiveC4.

the class CPacketPlayerRecipeSelection method handle.

public static void handle(CPacketPlayerRecipeSelection pPacket, Supplier<NetworkEvent.Context> pContext) {
    pContext.get().enqueueWork(() -> {
        ServerPlayer sender = pContext.get().getSender();
        if (sender != null) {
            AbstractContainerMenu container = sender.containerMenu;
            sender.level.getRecipeManager().byKey(pPacket.recipe).ifPresent(recipe -> {
                PolymorphApi.common().getRecipeData(sender).ifPresent(recipeData -> recipeData.selectRecipe(recipe));
                for (AbstractCompatibilityModule integration : PolymorphIntegrations.get()) {
                    if (integration.selectRecipe(container, recipe)) {
                        return;
                    }
                }
                container.slotsChanged(sender.getInventory());
                if (container instanceof ItemCombinerMenu) {
                    ((ItemCombinerMenu) container).createResult();
                }
            });
        }
    });
    pContext.get().setPacketHandled(true);
}
Also used : AbstractContainerMenu(net.minecraft.world.inventory.AbstractContainerMenu) ServerPlayer(net.minecraft.server.level.ServerPlayer) AbstractCompatibilityModule(top.theillusivec4.polymorph.common.integration.AbstractCompatibilityModule) ItemCombinerMenu(net.minecraft.world.inventory.ItemCombinerMenu)

Aggregations

ServerPlayer (net.minecraft.server.level.ServerPlayer)1 AbstractContainerMenu (net.minecraft.world.inventory.AbstractContainerMenu)1 ItemCombinerMenu (net.minecraft.world.inventory.ItemCombinerMenu)1 AbstractCompatibilityModule (top.theillusivec4.polymorph.common.integration.AbstractCompatibilityModule)1