Search in sources :

Example 1 with ScreenHandlerSlotUpdateS2CPacket

use of net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket in project MCDoom by AzureDoom.

the class GunTableScreenHandler method updateResult.

protected static void updateResult(int syncId, World world, PlayerEntity player, GunTableInventory craftingInventory) {
    if (!world.isClient) {
        ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) player;
        ItemStack itemStack = ItemStack.EMPTY;
        Optional<GunTableRecipe> optional = world.getServer().getRecipeManager().getFirstMatch(Type.INSTANCE, craftingInventory, world);
        if (optional.isPresent()) {
            GunTableRecipe craftingRecipe = optional.get();
            itemStack = craftingRecipe.craft(craftingInventory);
        }
        craftingInventory.setStack(5, itemStack);
        serverPlayerEntity.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(syncId, 0, 5, itemStack));
    }
}
Also used : ScreenHandlerSlotUpdateS2CPacket(net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket) GunTableRecipe(mod.azure.doom.util.recipes.GunTableRecipe) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack)

Aggregations

GunTableRecipe (mod.azure.doom.util.recipes.GunTableRecipe)1 ItemStack (net.minecraft.item.ItemStack)1 ScreenHandlerSlotUpdateS2CPacket (net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1