Jump to content

Simple block capabilities-like system


Recommended Posts

As the Optional annotation has now disappeared in favour of capabilities, there is now no way to add optional features to non-TileEntity blocks.

An example use case would be proper fluid handling for vanilla cauldrons, or handling of different blocks' "heat" values.


It would have to return a function (BlockState, IWorldReader) -> custom capability instance. And couldn't be cached without more work. The capability would also not be able to be serialisable to NBT (obviously non-TEs don't have NBT).


It would effectively be a mapping of blockstate -> capability.

If we restricted it to readonly capabilities there would be no issues with modders caching the capability and modifying something they shouldn't, but it would for example allow extraction from cauldrons, but not insertion.

The optimum solution would be for the capabilities to be cached when first accessed (Probably by calling World/Chunk#getBlockCapability(Capability, BlockPos)) which would then be returned every time afterwards (until the position was unloaded).


It would allow ModB to support ModA's X system, without having to inherit from an API which may not exist at runtime.


This post is intended as the starting point of a discussion, if it is an idea that no-one is interested in, that is fine.

The alternative is to just ship ModA's API with ModB, or at least the interfaces you are implementing in your block, but that has no way of adding capabilities to blocks which you don't own (e.g. vanilla cauldrons, torches).

  • Like 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.