Finally Got Potions (ItemMeta) and Signs (BlockState) working

So one of the long-standing requests from the boys has been that we have the ability to create potions from Pycraft's in-game REPL. Today I finally got that working, mostly because I finally decided that there was room for a reference pattern to make the whole thing easier.

By way of background, Pycraft was previously an "indexable object only" or "nameable object only" model of RPC, so you could only call methods on an object which had a direct path of lookup, so you could lookup a block by location, or an inventory by the holder of the inventory, or an itemstack by the inventory that held it, but there was no support for transient objects that would hold data, be used, then be discarded.

Bukkit (and derivatives, such as Spigot, Paper, etc) has a few cases where temporary objects are needed. For potions, you need to:

* get the item-stack (potion) to modify
* get the item-stack's metadata to modify (this is a temporary object)
* set the metadata's base potion data (which is a data object)
* set the item-stack's metadata to the new, modified metadata

which means that you needed to keep a reference to the server-side object alive for the time needed to complete the Python function. So, today I bit the bullet and let it happen. I don't really like the distributed reference-collection model, but it does allow the features requested.

Still working on getting potion custom effects working, but maybe next time.


Comments are closed.


Pingbacks are closed.