@SuppressWarnings("unchecked")
 public static void tryModulePhaseRegistration(RegistryModule module) {
   try {
     if (requiresCustomRegistration(module)) {
       if (isCustomProperPhase(module)) {
         Method method = getCustomRegistration(module);
         invokeCustomRegistration(
             module, checkNotNull(method, "Custom registration module was null!"));
       }
     } else {
       if (hasCatalogRegistration(module) && isDefaultProperPhase(module)) {
         module.registerDefaults();
         Map<String, ?> map = getCatalogMap(module);
         if (map.isEmpty()) {
           return;
         }
         if (module instanceof ItemTypeRegistryModule) {
           Map<String, ItemType> itemTypeMap = new HashMap<>();
           for (Map.Entry<String, ItemType> entry : ((Map<String, ItemType>) map).entrySet()) {
             itemTypeMap.put(entry.getKey().replace("minecraft:", ""), entry.getValue());
           }
           RegistryHelper.mapFields(ItemTypes.class, itemTypeMap);
         } else if (module instanceof BlockTypeRegistryModule) {
           Map<String, BlockType> blockMap = new HashMap<>();
           for (Map.Entry<String, BlockType> entry : ((Map<String, BlockType>) map).entrySet()) {
             blockMap.put(entry.getKey().replace("minecraft:", ""), entry.getValue());
           }
           RegistryHelper.mapFields(BlockTypes.class, blockMap);
         } else {
           RegistryHelper.mapFields(getCatalogClass(module), map);
         }
       }
     }
   } catch (Exception e) {
     throw new RuntimeException(
         "Error trying to initialize module: " + module.getClass().getCanonicalName(), e);
   }
 }
Esempio n. 2
0
 public static void registerKeys() {
   keyMap.put("axis", makeSingleKey(Axis.class, Value.class, of("Axis")));
   keyMap.put("color", makeSingleKey(Color.class, Value.class, of("Color")));
   keyMap.put("health", makeSingleKey(Double.class, MutableBoundedValue.class, of("Health")));
   keyMap.put(
       "max_health", makeSingleKey(Double.class, MutableBoundedValue.class, of("MaxHealth")));
   keyMap.put(
       "shows_display_name", makeSingleKey(Boolean.class, Value.class, of("ShowDisplayName")));
   keyMap.put("display_name", makeSingleKey(Text.class, Value.class, of("DisplayName")));
   keyMap.put("career", makeSingleKey(Career.class, Value.class, of("Career")));
   keyMap.put("sign_lines", makeListKey(Text.class, of("SignLines")));
   keyMap.put("skull_type", makeSingleKey(SkullType.class, Value.class, of("SkullType")));
   keyMap.put("velocity", makeSingleKey(Vector3d.class, Value.class, of("Velocity")));
   keyMap.put("eye_height", makeSingleKey(Double.class, Value.class, of("EyeHeight")));
   keyMap.put("eye_location", makeSingleKey(Vector3d.class, Value.class, of("EyeLocation")));
   keyMap.put("food_level", makeSingleKey(Integer.class, Value.class, of("FoodLevel")));
   keyMap.put("saturation", makeSingleKey(Double.class, Value.class, of("FoodSaturationLevel")));
   keyMap.put("exhaustion", makeSingleKey(Double.class, Value.class, of("FoodExhaustionLevel")));
   keyMap.put("max_air", makeSingleKey(Integer.class, Value.class, of("MaxAir")));
   keyMap.put("remaining_air", makeSingleKey(Integer.class, Value.class, of("RemainingAir")));
   RegistryHelper.mapFields(Keys.class, keyMap);
 }