Search in sources :

Example 1 with IRecipe

use of net.minecraft.server.v1_13_R1.IRecipe in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    if (!world.isClientSide) {
        EntityPlayer entityplayer = (EntityPlayer) ((CraftHumanEntity) viewer).getHandle();
        ItemStack itemstack = ItemStack.a;
        IRecipe irecipe = CraftingManager.b(craftInventory, world);
        if ((irecipe != null) && ((irecipe.c()) || (!world.getGameRules().getBoolean("doLimitedCrafting")) || (entityplayer.F().b(irecipe)))) {
            resultInventory.a(irecipe);
            itemstack = irecipe.craftItem(craftInventory);
        }
        itemstack = CraftEventFactory.callPreCraftEvent(craftInventory, itemstack, getBukkitView(), false);
        resultInventory.setItem(0, itemstack);
        entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));
        for (Object listener : listeners) {
            EntityPlayer player = (EntityPlayer) listener;
            player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, itemstack));
        }
    }
}
Also used : IRecipe(net.minecraft.server.v1_12_R1.IRecipe) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_12_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 2 with IRecipe

use of net.minecraft.server.v1_13_R1.IRecipe in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    if (!world.isClientSide) {
        EntityPlayer entityplayer = (EntityPlayer) ((CraftHumanEntity) viewer).getHandle();
        ItemStack itemstack = ItemStack.a;
        IRecipe irecipe = world.getMinecraftServer().getCraftingManager().b(craftInventory, world);
        if ((resultInventory.a(world, entityplayer, irecipe)) && (irecipe != null)) {
            resultInventory.a(irecipe);
            itemstack = irecipe.craftItem(craftInventory);
        }
        itemstack = CraftEventFactory.callPreCraftEvent(craftInventory, resultInventory, itemstack, getBukkitView(), false);
        resultInventory.setItem(0, itemstack);
        entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));
        for (Object listener : listeners) {
            EntityPlayer player = (EntityPlayer) listener;
            player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, itemstack));
        }
    }
}
Also used : IRecipe(net.minecraft.server.v1_13_R2.IRecipe) EntityPlayer(net.minecraft.server.v1_13_R2.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_13_R2.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_13_R2.ItemStack)

Example 3 with IRecipe

use of net.minecraft.server.v1_13_R1.IRecipe in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    if (!world.isClientSide) {
        EntityPlayer entityplayer = (EntityPlayer) ((CraftHumanEntity) viewer).getHandle();
        ItemStack itemstack = ItemStack.a;
        IRecipe irecipe = world.getMinecraftServer().getCraftingManager().b(craftInventory, world);
        if ((resultInventory.a(world, entityplayer, irecipe)) && (irecipe != null)) {
            resultInventory.a(irecipe);
            itemstack = irecipe.craftItem(craftInventory);
        }
        itemstack = CraftEventFactory.callPreCraftEvent(craftInventory, resultInventory, itemstack, getBukkitView(), false);
        resultInventory.setItem(0, itemstack);
        entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));
        for (Object listener : listeners) {
            EntityPlayer player = (EntityPlayer) listener;
            player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, itemstack));
        }
    }
}
Also used : IRecipe(net.minecraft.server.v1_13_R1.IRecipe) EntityPlayer(net.minecraft.server.v1_13_R1.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_13_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_13_R1.ItemStack)

Aggregations

EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)1 IRecipe (net.minecraft.server.v1_12_R1.IRecipe)1 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)1 PacketPlayOutSetSlot (net.minecraft.server.v1_12_R1.PacketPlayOutSetSlot)1 EntityPlayer (net.minecraft.server.v1_13_R1.EntityPlayer)1 IRecipe (net.minecraft.server.v1_13_R1.IRecipe)1 ItemStack (net.minecraft.server.v1_13_R1.ItemStack)1 PacketPlayOutSetSlot (net.minecraft.server.v1_13_R1.PacketPlayOutSetSlot)1 EntityPlayer (net.minecraft.server.v1_13_R2.EntityPlayer)1 IRecipe (net.minecraft.server.v1_13_R2.IRecipe)1 ItemStack (net.minecraft.server.v1_13_R2.ItemStack)1 PacketPlayOutSetSlot (net.minecraft.server.v1_13_R2.PacketPlayOutSetSlot)1