Skip to content

Item Usage Context

mitsudz edited this page Aug 13, 2024 · 1 revision

ItemUsageContext

The ItemUsageContext is intended as an alternative to using Objects... in the type-signature of the useItem function. The useItem function may require variable inputs depending on the type of item and context in which it is being used. Using Objects... to achieve this would bypass Java's type checking features, and require each new item to cast and check inputs directly. A hacked together solution to avoid this and engage type-checking, is the ItemUsageContext class. This is a class with (in future) many constructors, and simply stores inputs as class members. In this way, if a new item requires a new set of inputs, we simply add a relevant constructor to the ItemUsageContext class.

Note - when a new item is added, it must be added to the javadoc of the relevant constructor of ItemUsageContext which it uses.

Clone this wiki locally