This is a static snapshot of the site saved for posterity. No future updates will be made here and all interactive features (comments, etc.) are disabled.

Reflection

 

This is highly not recommended, in most cases you do not need to use this.

  • {classname}({methodname})[@{meta}] – This will invoke a static, parameter-less method of the specified class
  • {classname}[{fieldname}][@{meta}] – This will retrieve a static field of the specified class

In both cases:

  • {classname} should be fully qualified with the package name
  • If the result is an Item or Block instance – it will be converted to an ItemStack with the specified meta/damage
    • If meta is not specified – it will default either to 0 or to a wildcard value, depending on context
  • If the result is an ItemStack – it will be used as is
    • If meta specified – it will override the returned one and a warning will be logged

Class Macros 

You can specify a macro for class names:

def {identifier} = {classname}

The identifier can then be used instead of the full class name as:

${identifier}({methodname})[@{meta}] or ${identifier}[{fieldname}][@{meta}]

Class macros can only appear in Recipe Blocks and are local to the block they appear in
com.someauthor.foomod.Items[itemBar] 
/* Will find a class named Items in package 
   com.someauthor.foomod and get a static field 
   named itemBar */

com.someauthor.foomod.Items(getBar) 
/* ditto, but will instead call a static method named getBar */

def fooItems = com.someauthor.foomod.Items 

$fooItems[itemBar] // Those 2 are equivalent to the above 
$fooItems(getBar)
 Posted by at 7:46 am