Changes

856 bytes added ,  19:50, 13 June 2022
Fix ObjectHolder info
Line 169: Line 169:  
*** the '''enclosing class''' has an <code>@ObjectHolder</code> annotation, and the field is <code>final</code>, and:
 
*** the '''enclosing class''' has an <code>@ObjectHolder</code> annotation, and the field is <code>final</code>, and:
 
**** the name value is the field's name; and
 
**** the name value is the field's name; and
 +
**** the registry name value is the name of the object's registry; and
 
**** the namespace value is the enclosing class's namespace
 
**** the namespace value is the enclosing class's namespace
 
**** ''An exception is thrown if the namespace value cannot be found and inherited''
 
**** ''An exception is thrown if the namespace value cannot be found and inherited''
 
*** the '''field''' is annotated with <code>@ObjectHolder</code>, and:
 
*** the '''field''' is annotated with <code>@ObjectHolder</code>, and:
 
**** the name value is explicitly defined; and
 
**** the name value is explicitly defined; and
 +
**** the registry name value is either explicitly defined or the enclosing class's registry name; and
 
**** the namespace value is either explicitly defined or the enclosing class's namespace
 
**** the namespace value is either explicitly defined or the enclosing class's namespace
** the field type or one of its supertypes corresponds to a valid registry (e.g. <code>Item</code> or <code>ArrowItem</code> for the <code>Item</code> registry)
   
** ''An exception is thrown if a field does not have a corresponding registry.''
 
** ''An exception is thrown if a field does not have a corresponding registry.''
 
* ''An exception is thrown if the resulting <code>ResourceLocation</code> is incomplete or invalid (non-valid characters in path)''
 
* ''An exception is thrown if the resulting <code>ResourceLocation</code> is incomplete or invalid (non-valid characters in path)''
Line 189: Line 190:  
<div class="mw-collapsible-content" style="overflow: auto; white-space: nowrap;">
 
<div class="mw-collapsible-content" style="overflow: auto; white-space: nowrap;">
 
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
@ObjectHolder("minecraft") // Inheritable resource namespace: "minecraft"
+
@ObjectHolder(registryName = "block", value = "minecraft") // Registry: minecraft:block, Inheritable resource namespace: "minecraft"
 
class AnnotatedHolder {
 
class AnnotatedHolder {
 
     public static final Block diamond_block = null;  // No annotation. [public static final] is required.
 
     public static final Block diamond_block = null;  // No annotation. [public static final] is required.
                                                       // Block has a corresponding registry: [Block]
+
                                                       // Registry name is not explicitly defined.
 +
                                                      // So, registry name is inherited from class annotation: "minecraft:block"
 
                                                       // Name path is the name of the field: "diamond_block"
 
                                                       // Name path is the name of the field: "diamond_block"
 
                                                       // Namespace is not explicitly defined.
 
                                                       // Namespace is not explicitly defined.
Line 198: Line 200:  
                                                       // To inject: "minecraft:diamond_block" from the [Block] registry
 
                                                       // To inject: "minecraft:diamond_block" from the [Block] registry
   −
     @ObjectHolder("ambient.cave")
+
     @ObjectHolder(registry = "sound_event", value = "ambient.cave")
 
     public static SoundEvent ambient_sound = null;    // Annotation present. [public static] is required.
 
     public static SoundEvent ambient_sound = null;    // Annotation present. [public static] is required.
                                                       // SoundEvent has a corresponding registry: [SoundEvent]
+
                                                       // Registry name is explicitly defined: "minecraft:sound_event"
 
                                                       // Name path is the value of the annotation: "ambient.cave"
 
                                                       // Name path is the value of the annotation: "ambient.cave"
 
                                                       // Namespace is not explicitly defined.
 
                                                       // Namespace is not explicitly defined.
Line 207: Line 209:     
     // Assume for the next entry that [ManaType] is a valid registry.           
 
     // Assume for the next entry that [ManaType] is a valid registry.           
     @ObjectHolder("neomagicae:coffeinum")
+
     @ObjectHolder(registryName = "neomagicae:mana_type", value = "neomagicae:coffeinum")
 
     public static final ManaType coffeinum = null;    // Annotation present. [public static] is required. [final] is optional.
 
     public static final ManaType coffeinum = null;    // Annotation present. [public static] is required. [final] is optional.
                                                       // ManaType has a corresponding registry: [ManaType] (custom registry)
+
                                                       // Registry name is explicitly defined: "neomagicae:mana_type" (custom registry)
 
                                                       // Resource location is explicitly defined: "neomagicae:coffeinum"
 
                                                       // Resource location is explicitly defined: "neomagicae:coffeinum"
 
                                                       // To inject: "neomagicae:coffeinum" from the [ManaType] registry
 
                                                       // To inject: "neomagicae:coffeinum" from the [ManaType] registry
    
     public static final Item ENDER_PEARL = null;      // No annotation. [public static final] is required.
 
     public static final Item ENDER_PEARL = null;      // No annotation. [public static final] is required.
                                                       // Item has a corresponding registry: [Item].
+
                                                       // Registry name is not explicitly defined.
 +
                                                      // So, registry name is inherited from class annotation: "minecraft:block"
 
                                                       // Name path is the name of the field: "ENDER_PEARL" -> "ender_pearl"
 
                                                       // Name path is the name of the field: "ENDER_PEARL" -> "ender_pearl"
 
                                                       // !! ^ Field name is valid, because they are
 
                                                       // !! ^ Field name is valid, because they are
Line 220: Line 223:  
                                                       // Namespace is not explicitly defined.
 
                                                       // Namespace is not explicitly defined.
 
                                                       // So, namespace is inherited from class annotation: "minecraft"
 
                                                       // So, namespace is inherited from class annotation: "minecraft"
                                                       // To inject: "minecraft:ender_pearl" from the [Item] registry
+
                                                       // When registering, this will attempt to force into a Block type, which is not a type or supertype of this object.
 +
                                                      // Therefore, THIS WILL PRODUCE AN EXCEPTION.
   −
     @ObjectHolder("minecraft:arrow")
+
     @ObjectHolder(registryName = "item", value = "minecraft:arrow")
 
     public static final ArrowItem arrow = null;      // Annotation present. [public static] is required. [final] is optional.
 
     public static final ArrowItem arrow = null;      // Annotation present. [public static] is required. [final] is optional.
                                                       // ArrowItem does not have a corresponding registry.
+
                                                       // Registry name is explicitly defined: "minecraft:item"
 
                                                       // ArrowItem's supertype of Item has a corresponding registry: [Item]
 
                                                       // ArrowItem's supertype of Item has a corresponding registry: [Item]
 
                                                       // Resource location is explicitly defined: "minecraft:arrow"
 
                                                       // Resource location is explicitly defined: "minecraft:arrow"
Line 233: Line 237:  
      
 
      
 
     public static final CreativeModeTab group = null; // No annotation. [public static final] is required.
 
     public static final CreativeModeTab group = null; // No annotation. [public static final] is required.
                                                       // CreativeModeTab does not have a corresponding registry.
+
                                                       // Registry name is not explicitly defined.
                                                       // No supertypes of CreativeModeTab has a corresponding registry.
+
                                                      // So, registry name is inherited from class annotation: "minecraft:block"
 +
                                                       // When registering, this will attempt to force into a Block type, which is not a type or supertype of this object.
 
                                                       // Therefore, THIS WILL PRODUCE AN EXCEPTION.
 
                                                       // Therefore, THIS WILL PRODUCE AN EXCEPTION.
 
}
 
}
    
class UnannotatedHolder { // Note the lack of an @ObjectHolder annotation on this class.
 
class UnannotatedHolder { // Note the lack of an @ObjectHolder annotation on this class.
     @ObjectHolder("minecraft:flame")
+
     @ObjectHolder(registryName = "enchantment", value = "minecraft:flame")
 
     public static final Enchantment flame = null;    // Annotation present. [public static] is required. [final] is optional.
 
     public static final Enchantment flame = null;    // Annotation present. [public static] is required. [final] is optional.
                                                       // Enchantment has corresponding registry: [Enchantment].
+
                                                       // Registry name is explicitly defined: "minecraft:enchantment"
 
                                                       // Resource location is explicitly defined: "minecraft:flame"
 
                                                       // Resource location is explicitly defined: "minecraft:flame"
 
                                                       // To inject: "minecraft:flame" from the [Enchantment] registry
 
                                                       // To inject: "minecraft:flame" from the [Enchantment] registry
Line 251: Line 256:  
     public static Entity creeper = null;              // Annotation present. [public static] is required.
 
     public static Entity creeper = null;              // Annotation present. [public static] is required.
 
                                                       // Entity does not have a corresponding registry.
 
                                                       // Entity does not have a corresponding registry.
                                                       // No supertypes of Entity has a corresponding registry.
+
                                                       // The registry has not been specified on the class.
 
                                                       // Therefore, THIS WILL PRODUCE AN EXCEPTION.
 
                                                       // Therefore, THIS WILL PRODUCE AN EXCEPTION.
   −
     @ObjectHolder("levitation")
+
     @ObjectHolder(registryName = "potion", value = "levitation")
 
     public static final Potion levitation = null;    // Annotation present. [public static] is required. [final] is optional.
 
     public static final Potion levitation = null;    // Annotation present. [public static] is required. [final] is optional.
                                                       // Potion has a corresponding registry: [Potion].
+
                                                       // Registry name is explicitly defined: "minecraft:potion"
 
                                                       // Name path is the value of the annotation: "levitation"
 
                                                       // Name path is the value of the annotation: "levitation"
 
                                                       // Namespace is not explicitly defined.
 
                                                       // Namespace is not explicitly defined.