Updating Minecart Mania - Old Methods

Discussion in 'Plugin Development' started by Sparmerlin, May 2, 2016.

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

    Sparmerlin

    Hi Everyone,

    I'm currently in the process of updating Minecart Mania Reborn.
    I've almost finished but one bug has me stuck!

    Code:
        public Inventory getBukkitInventory() {
            InventoryLargeChest large = new InventoryLargeChest("Large Chest", ((CraftInventory)chest1.getBukkitInventory()).getInventory(), ((CraftInventory)chest2.getBukkitInventory()).getInventory());
            return new CraftInventory(large);
        }
    Thats the original code using some older methods from craftbukkit v1_4_6.
    I'm not sure how to convert this to the newer versions of craftbukkit.

    Does anyone know the solution to this problem?

    Thanks,
    Luke (sparmerlin).
     
  2. Offline

    I Al Istannen

    MisterErwin likes this.
  3. Offline

    Abstract97

    @Sparmerlin I believe you can use the same code, just change the imports from the old 1.6 import to the new 1.7 or 1.8 version.

    For 1.6 it will look like:

    Code:java
    1. import net.minecraft.server.v1_6_R4.InventoryLargeChest;


    change it to (or whatever version you are using)

    Code:java
    1. import net.minecraft.server.v1_7_R4.InventoryLargeChest;
     
  4. Offline

    I Al Istannen

    @Abstract97
    Either I understood the code wrong (i.e. he doesn't want to create an inventory, or there is something special with the InventoryLargeChest) or there is no need for NMS. I would avoid it where I could, as it makes it version dependent.
     
  5. Offline

    Abstract97

  6. Offline

    I Al Istannen

    @Abstract97
    That would be a bit more helpful if you corrected me. I mean, it returns an Inventory and that is also what Bukkit.createInventory with a type of CHEST and a size of 54 does.
     
  7. Offline

    Abstract97

    @I Al Istannen Did you not read the full thing, its getting the inventory of two chests, it combines two INDIVIDUAL chests, to create one full large chest inventory, I don't see any code of it 'Creating' an inventory from scratch.

    Code:java
    1. ((CraftInventory)chest1.getBukkitInventory()).getInventory(), ((CraftInventory)chest2.getBukkitInventory()).getInventory()
     
    Sparmerlin likes this.
  8. Offline

    I Al Istannen

    @Abstract97
    Ah, completly skipped chest1 and chest2. Thanks for pointing that out! I would still not use NMS, but I can see why they did it.
     
    Sparmerlin likes this.
Thread Status:
Not open for further replies.

Share This Page