{CraftingManager.a()} Help I don't know how to fix it?

Discussion in 'Plugin Development' started by Jessy1237, Sep 30, 2011.

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

    Jessy1237

    Ok so I have this outdated class and I decided to fix it today and well somehting went wrong with the crafting scheduler. I'm just puzzled I can't find the fix.
    The errors are:
    • The method a() is undefined for the type CraftingManager
    • The field Container.a is not visible
    • The field Container.b is not visible
    Here is the class:
    Code:JAVA
    1.  
    2. import net.minecraft.server.CraftingManager;
    3. import net.minecraft.server.EntityPlayer;
    4. import net.minecraft.server.ItemStack;
    5.  
    6. import org.bukkit.craftbukkit.entity.CraftPlayer;
    7. import net.minecraft.server.ContainerWorkbench;
    8. import net.minecraft.server.ContainerPlayer;
    9.  
    10. public class DCCraftSchedule implements Runnable {
    11. private final DCPlayer dCPlayer;
    12. private final DwarfCraft plugin;
    13. private final EntityPlayer entityPlayer;
    14. private int taskID;
    15.  
    16. public DCCraftSchedule(DwarfCraft newPlugin, DCPlayer newDwarf) {
    17. this.dCPlayer = newDwarf;
    18. this.plugin = newPlugin;
    19. this.entityPlayer = ((CraftPlayer) (dCPlayer.getPlayer())).getHandle();
    20. }
    21.  
    22. public void setID(int id){
    23. taskID = id;
    24. }
    25.  
    26. @Override
    27. public void run() {
    28. // in this task we need to check to see if they are still using a
    29. // craftbench. if so, continue the task.
    30.  
    31. if (entityPlayer == null || entityPlayer.activeContainer == entityPlayer.defaultContainer){
    32. kill();
    33. return;
    34. }
    35. ItemStack outputStack = null;
    36. if (entityPlayer.activeContainer instanceof ContainerPlayer){
    37. ContainerPlayer player = (ContainerPlayer)(entityPlayer.activeContainer);
    38. outputStack = CraftingManager.a().a(player.a);
    39. }else if (entityPlayer.activeContainer instanceof ContainerWorkbench){
    40. ContainerWorkbench workBench = (ContainerWorkbench)(entityPlayer.activeContainer);
    41. outputStack = CraftingManager.a().a(workBench.a);
    42. }else {
    43. kill();
    44. return;
    45. }
    46. if (outputStack != null) {
    47. int materialId = outputStack.id;
    48. int damage = outputStack.damage;
    49. for (Skill s : dCPlayer.getSkills().values()) {
    50. for (Effect e : s.getEffects()) {
    51. if (e.getEffectType() == EffectType.CRAFT && e.checkInitiator(materialId, (byte)damage)){
    52.  
    53. org.bukkit.inventory.ItemStack output = e.getOutput(dCPlayer, (byte)damage);
    54.  
    55. if (output.getAmount() == 0)
    56. outputStack = null;
    57. else{
    58. outputStack.count = output.getAmount();
    59. if (output.getData() != null)
    60. outputStack.damage = output.getData().getData();
    61. }
    62. // TODO: need code to check max stack size and if amount
    63. // created > max stack size drop all count above 1 to
    64. // ground/inventory.
    65. // I'm not sure what the server ItemStack method is for
    66. // is.getMaxStackSize()
    67. }
    68. }
    69. if (entityPlayer.activeContainer instanceof ContainerPlayer){
    70. ContainerPlayer player = (ContainerPlayer)(entityPlayer.activeContainer);
    71. player.b.setItem(0, outputStack);
    72. }else if (entityPlayer.activeContainer instanceof ContainerWorkbench){
    73. ContainerWorkbench workBench = (ContainerWorkbench)(entityPlayer.activeContainer);
    74. workBench.b.setItem(0, outputStack);
    75. }
    76. }
    77. }
    78. plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new DCCraftSchedule(plugin, dCPlayer), 2);
    79. }
    80. public void kill() {
    81. plugin.getServer().getScheduler().cancelTask(taskID);
    82. }
    83. }
    84.  


    If that is hard to read use this:
    Show Spoiler

    import net.minecraft.server.CraftingManager;
    import net.minecraft.server.EntityPlayer;
    import net.minecraft.server.ItemStack;

    import org.bukkit.craftbukkit.entity.CraftPlayer;
    import net.minecraft.server.ContainerWorkbench;
    import net.minecraft.server.ContainerPlayer;

    public class DCCraftSchedule implements Runnable {
    private final DCPlayer dCPlayer;
    private final DwarfCraft plugin;
    private final EntityPlayer entityPlayer;
    private int taskID;

    public DCCraftSchedule(DwarfCraft newPlugin, DCPlayer newDwarf) {
    this.dCPlayer = newDwarf;
    this.plugin = newPlugin;
    this.entityPlayer = ((CraftPlayer) (dCPlayer.getPlayer())).getHandle();
    }

    public void setID(int id){
    taskID = id;
    }

    @Override
    public void run() {
    // in this task we need to check to see if they are still using a
    // craftbench. if so, continue the task.

    if (entityPlayer == null || entityPlayer.activeContainer == entityPlayer.defaultContainer){
    kill();
    return;
    }
    ItemStack outputStack = null;
    if (entityPlayer.activeContainer instanceof ContainerPlayer){
    ContainerPlayer player = (ContainerPlayer)(entityPlayer.activeContainer);
    outputStack = CraftingManager.a().a(player.a);
    }else if (entityPlayer.activeContainer instanceof ContainerWorkbench){
    ContainerWorkbench workBench = (ContainerWorkbench)(entityPlayer.activeContainer);
    outputStack = CraftingManager.a().a(workBench.a);
    }else {
    kill();
    return;
    }
    if (outputStack != null) {
    int materialId = outputStack.id;
    int damage = outputStack.damage;
    for (Skill s : dCPlayer.getSkills().values()) {
    for (Effect e : s.getEffects()) {
    if (e.getEffectType() == EffectType.CRAFT && e.checkInitiator(materialId, (byte)damage)){

    org.bukkit.inventory.ItemStack output = e.getOutput(dCPlayer, (byte)damage);

    if (output.getAmount() == 0)
    outputStack = null;
    else{
    outputStack.count = output.getAmount();
    if (output.getData() != null)
    outputStack.damage = output.getData().getData();
    }
    // TODO: need code to check max stack size and if amount
    // created > max stack size drop all count above 1 to
    // ground/inventory.
    // I'm not sure what the server ItemStack method is for
    // is.getMaxStackSize()
    }
    }
    if (entityPlayer.activeContainer instanceof ContainerPlayer){
    ContainerPlayer player = (ContainerPlayer)(entityPlayer.activeContainer);
    player.b.setItem(0, outputStack);
    }else if (entityPlayer.activeContainer instanceof ContainerWorkbench){
    ContainerWorkbench workBench = (ContainerWorkbench)(entityPlayer.activeContainer);
    workBench.b.setItem(0, outputStack);
    }
    }
    }
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new DCCraftSchedule(plugin, dCPlayer), 2);
    }
    public void kill() {
    plugin.getServer().getScheduler().cancelTask(taskID);
    }
    }


    Thanks in Advance For any Help.

    Note: I have the "package blah.blah.blah;" there its just not in the code here.
     
  2. Offline

    zhuowei

    I tried to fix the version in the spoiler. The source code for the net.minecraft.server classes is in http://github.com/bukkit/mc-dev and you can consult them to try to find the missing methods. Also, you might consider rewriting this part of the plugin to use Spout's ability to access crafting grids.
     
  3. Offline

    Jessy1237

    Thanks zhuowei, I will research into the spout crafting grids.
     
Thread Status:
Not open for further replies.

Share This Page