Search in sources :

Example 1 with SSetSlotPacket

use of net.minecraft.network.play.server.SSetSlotPacket in project BluePower by Qmunity.

the class ContainerProjectTable method updateCrafting.

protected static void updateCrafting(int id, World world, PlayerEntity playerEntity, CraftingInventory craftingInventory, CraftResultInventory craftResultInventory) {
    if (!world.isClientSide) {
        ServerPlayerEntity serverplayerentity = (ServerPlayerEntity) playerEntity;
        ItemStack itemstack = ItemStack.EMPTY;
        Optional<ICraftingRecipe> optional = world.getServer().getRecipeManager().getRecipeFor(IRecipeType.CRAFTING, craftingInventory, world);
        if (optional.isPresent()) {
            ICraftingRecipe icraftingrecipe = optional.get();
            if (craftResultInventory.setRecipeUsed(world, serverplayerentity, icraftingrecipe)) {
                itemstack = icraftingrecipe.assemble(craftingInventory);
            }
        }
        craftResultInventory.setItem(0, itemstack);
        serverplayerentity.connection.send(new SSetSlotPacket(id, 0, itemstack));
    }
}
Also used : SSetSlotPacket(net.minecraft.network.play.server.SSetSlotPacket) ICraftingRecipe(net.minecraft.item.crafting.ICraftingRecipe) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 ICraftingRecipe (net.minecraft.item.crafting.ICraftingRecipe)1 SSetSlotPacket (net.minecraft.network.play.server.SSetSlotPacket)1