Inventory/result of a workbench

Discussion in 'Plugin Development' started by Piedo_bear, Mar 21, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Piedo_bear

    Is it possible to find out the current contents of the workbench and its result?

    I'd like to effectively disable a recipe for certain users.

    Shed some light on how I might be able to do this please, if at all :)
     
  2. Offline

    Edward Hand

    A similar plugin exists here:
    http://forums.bukkit.org/threads/me...es-limited-only-by-your-imagination-493.5993/

    I was the one who provided fullwall with the basic code for interfacing with the crafting inventory so I should be able to help you.

    you can get the contents of a workbench as follows:
    Code:
    CraftPlayer cPlayer = (CraftPlayer)thePlayer;
    Container container = thePlayer().getHandle().activeContainer;
    net.minecraft.server.ItemStack[] contents = null;
    if(container instanceof ContainerWorkbench)
        contents = container.a.getContents()
    That will give you an array of 9 ItemStacks representing the contents of the workbench.
    Note: net.minecraft.server.ItemStack is not the same as org.bukkit.inventory.ItemStack. They have public 'count', 'id' and 'damage' properties.
     
Thread Status:
Not open for further replies.

Share This Page