Search in sources :

Example 1 with PacketPlayOutSetSlot

use of net.minecraft.server.v1_9_R2.PacketPlayOutSetSlot in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    CraftingManager.getInstance().lastCraftView = getBukkitView();
    ItemStack craftResult = CraftingManager.getInstance().craft(craftInventory, world);
    resultInventory.setItem(0, craftResult);
    if (listeners.isEmpty()) {
        return;
    }
    if ((craftResult != null) && (craftResult.getItem() == Items.FILLED_MAP)) {
        return;
    }
    for (Object listener : listeners) {
        EntityPlayer player = (EntityPlayer) listener;
        player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult));
    }
}
Also used : EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_11_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_11_R1.ItemStack)

Example 2 with PacketPlayOutSetSlot

use of net.minecraft.server.v1_9_R2.PacketPlayOutSetSlot 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 3 with PacketPlayOutSetSlot

use of net.minecraft.server.v1_9_R2.PacketPlayOutSetSlot 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 4 with PacketPlayOutSetSlot

use of net.minecraft.server.v1_9_R2.PacketPlayOutSetSlot in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    CraftingManager.getInstance().lastCraftView = getBukkitView();
    ItemStack craftResult = CraftingManager.getInstance().craft(craftInventory, world);
    resultInventory.setItem(0, craftResult);
    if (listeners.isEmpty()) {
        return;
    }
    if ((craftResult != null) && (craftResult.getItem() == Items.FILLED_MAP)) {
        return;
    }
    for (Object listener : listeners) {
        EntityPlayer player = (EntityPlayer) listener;
        player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult));
    }
}
Also used : EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_8_R3.ItemStack)

Example 5 with PacketPlayOutSetSlot

use of net.minecraft.server.v1_9_R2.PacketPlayOutSetSlot 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_10_R1.EntityPlayer)1 ItemStack (net.minecraft.server.v1_10_R1.ItemStack)1 PacketPlayOutSetSlot (net.minecraft.server.v1_10_R1.PacketPlayOutSetSlot)1 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)1 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)1 PacketPlayOutSetSlot (net.minecraft.server.v1_11_R1.PacketPlayOutSetSlot)1 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 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)1 ItemStack (net.minecraft.server.v1_8_R3.ItemStack)1