Thought experiment: Changing slabs to InventoryHolders via reflections

Discussion in 'Plugin Development' started by Father Of Time, May 8, 2012.

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

    Father Of Time

    Good afternoon all,

    So I have a quick thought experiment… unfortunately I am at work at the moment and don’t have the time to fully research this concept, but I figured I would share the concept with the community in hopes that someone will have some experience to share that will assist me with my research later this evening.

    So my question is this, using reflections or other means would it be possible to make the slab block type inherit from the Inventory Holder class like chest? My end goal is to make half slabs function exactly the same as a chest.

    I don’t believe I could change the actual inheritance of the block class itself, but could I create an extended class that does inherit from the Inventory Holder class and then load that into the static variable that stores block types at during compile using reflections?

    So in short, I create a new class that extends the slab class and inherits from the InventoryHolder class, then using reflections we would change the static variable stored in in bukkit:

          public static final Block DOUBLE_STEP = (new BlockStep(43, true)).c(2.0F).b(10.0F).a(h).a("stoneSlab");
    We would change the above variable from creating a normal slab to creating a new custom one that we’ve created that does inherit from the InventoryHolder. As far as anyone can see would this cause issues elsewhere in the Bukkit source?
  2. Offline


    I remember looking through some mojang code, finding that you can extend multiple classes. Perhaps creating a custom object with interaction events for your new "slab".

    1. public static newslab extends inventoryHolder, someotherclasshere

    Maybe change the metadata of that slab to distinguish it from other "slabs"
  3. Offline


    I don't think you can directly let the interface implement the inventory holder using reflection since you would need to add the methods as well. What you could do and what it most likely what dsmyth1915 said, is creating your own half slap which extends the normal halfslap but also implements the inventory holder interface. In theory that should probably work.

    Off topic:
    Father of Time do you mind reading my last pm :)?
Thread Status:
Not open for further replies.

Share This Page