Java 类net.minecraft.util.registry.IRegistry 实例源码

项目:EnderIO    文件:SmartModelAttacher.java   
@SuppressWarnings("null")
private static String debugOutput(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelResourceLocation defaultMrl, IBakedModel missingModel) {
  String prefix = defaultMrl.getResourceDomain() + ":" + defaultMrl.getResourcePath();
  if (modelRegistry instanceof RegistrySimple) {
    RegistrySimple<?, ?> rg = (RegistrySimple<?, ?>) modelRegistry;
    StringBuilder sb = new StringBuilder();
    for (Object key : rg.getKeys()) {
      if (modelRegistry.getObject((ModelResourceLocation) key) != missingModel && key.toString().startsWith(prefix)) {
        sb.append(key + "; ");
      }
    }
    if (sb.length() > 0) {
      sb.setLength(sb.length() - 2);
    } else {
      sb.append("(none)");
    }
    return "Loaded states for " + prefix + " are: " + sb.toString();
  } else {
    return "Loaded states could not be determined because modelRegistry is not a RegistrySimple.";
  }
}
项目:Backmemed    文件:ModelBakery.java   
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry()
{
    this.loadBlocks();
    this.loadVariantItemModels();
    this.loadModelsCheck();
    this.loadSprites();
    this.makeItemModels();
    this.bakeBlockModels();
    this.bakeItemModels();
    return this.bakedRegistry;
}
项目:CustomWorldGen    文件:ModelBakery.java   
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry()
{
    this.loadBlocks();
    this.loadVariantItemModels();
    this.loadModelsCheck();
    this.loadSprites();
    this.makeItemModels();
    this.bakeBlockModels();
    this.bakeItemModels();
    return this.bakedRegistry;
}
项目:MCAnm    文件:ModelLoader.java   
@SubscribeEvent
public static void atModelsBaked(ModelBakeEvent bakeEvent) {
    IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = bakeEvent.getModelRegistry();
    Map<ModelResourceLocation, IBakedModel> dependencies = new HashMap<>();
    for (IBakedModel model : modelRegistry) {
        if (!(model instanceof BakedModelWrapper)) {
            continue;
        }

        BakedModelWrapper bakedModel = (BakedModelWrapper) model;
        Set<ResourceLocation> overrideLocations = getDependencies(bakedModel);
        for (ResourceLocation dep : overrideLocations) {
            ModelResourceLocation actualDep = net.minecraftforge.client.model.ModelLoader
                    .getInventoryVariant(dep.toString());
            if (modelRegistry.getKeys().contains(actualDep)) {
                continue;
            }

            IModel depModel = ModelLoaderRegistry.getModelOrLogError(dep, "Missing dependency model");
            IBakedModel depBakedModel = depModel.bake(
                    depModel.getDefaultState(),
                    DefaultVertexFormats.ITEM,
                    EventListener::getTextureAtlas);
            dependencies.put(actualDep, depBakedModel);
        }
    }

    for (Entry<ModelResourceLocation, IBakedModel> entry : dependencies.entrySet()) {
        modelRegistry.putObject(entry.getKey(), entry.getValue());
    }
}
项目:ExpandedRailsMod    文件:ModelBakery.java   
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry()
{
    this.loadBlocks();
    this.loadVariantItemModels();
    this.loadModelsCheck();
    this.loadSprites();
    this.makeItemModels();
    this.bakeBlockModels();
    this.bakeItemModels();
    return this.bakedRegistry;
}
项目:CustomWorldGen    文件:ForgeHooksClient.java   
public static void onModelBake(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
{
    MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, modelLoader));
    modelLoader.onPostBakeEvent(modelRegistry);
}
项目:CustomWorldGen    文件:ModelLoader.java   
@Override
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry()
{
    isLoading = true;
    loadBlocks();
    loadVariantItemModels();
    missingModel = ModelLoaderRegistry.getMissingModel();
    stateModels.put(MODEL_MISSING, missingModel);

    final Set<ResourceLocation> textures = Sets.newHashSet(ModelLoaderRegistry.getTextures());
    textures.remove(TextureMap.LOCATION_MISSING_TEXTURE);
    textures.addAll(LOCATIONS_BUILTIN_TEXTURES);

    textureMap.loadSprites(resourceManager, new ITextureMapPopulator()
    {
        public void registerSprites(TextureMap map)
        {
            for(ResourceLocation t : textures)
            {
                map.registerSprite(t);
            }
        }
    });

    IBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE);
    Map<IModel, IBakedModel> bakedModels = Maps.newHashMap();
    HashMultimap<IModel, ModelResourceLocation> models = HashMultimap.create();
    Multimaps.invertFrom(Multimaps.forMap(stateModels), models);

    if (firstLoad)
    {
        firstLoad = false;
        for (ModelResourceLocation mrl : stateModels.keySet())
        {
            bakedRegistry.putObject(mrl, missingBaked);
        }
        return bakedRegistry;
    }

    ProgressBar bakeBar = ProgressManager.push("ModelLoader: baking", models.keySet().size());

    for(IModel model : models.keySet())
    {
        bakeBar.step("[" + Joiner.on(", ").join(models.get(model)) + "]");
        if(model == getMissingModel())
        {
            bakedModels.put(model, missingBaked);
        }
        else
        {
            bakedModels.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE));
        }
    }

    ProgressManager.pop(bakeBar);

    for (Entry<ModelResourceLocation, IModel> e : stateModels.entrySet())
    {
        bakedRegistry.putObject(e.getKey(), bakedModels.get(e.getValue()));
    }
    return bakedRegistry;
}
项目:CustomWorldGen    文件:ModelBakeEvent.java   
public ModelBakeEvent(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
{
    this.modelManager = modelManager;
    this.modelRegistry = modelRegistry;
    this.modelLoader = modelLoader;
}
项目:CustomWorldGen    文件:ModelBakeEvent.java   
public IRegistry<ModelResourceLocation, IBakedModel> getModelRegistry()
{
    return modelRegistry;
}
项目:taam    文件:TaamClientProxy.java   
@SubscribeEvent
    public void onModelBakeEvent(ModelBakeEvent event) {
        Log.debug("Beginning onModelBakeEvent");

        /*
         * We need to set the "flip-v" flag.. As the inventory-variant is
         * "generated" above, MC will ignore what we have in the blockstates
         * json & render the textures flipped in the inventory...
         *
         * Doing it via reflection, as we'd need to redefine the original
         * OBJModel somewhere (OBJModel.process() will do that) but I have no
         * idea WHERE!
         */

        // Currently not required due to custom replacement of OBJModel (Hacky workaround replaces Hacky Workaround)
//      Field customDataField = null;
//      Field customDataFlipVField = null;
//      try {
//          customDataField = OBJModel.class.getDeclaredField("customData");
//          customDataField.setAccessible(true);
//          Class<?> customDataType = customDataField.getType();
//          customDataFlipVField = customDataType.getDeclaredField("flipV");
//          customDataFlipVField.setAccessible(true);
//      } catch (Exception e) {
//          Log.error(
//                  "Failed to make OBJModel.customData accessible or access other reflection stuff. Inventory items will have wrong textures.",
//                  e);
//      }

        /*
         * Go through all registered locations from above & replace the baked
         * model with one that understands our items
         */

        IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
        for (ModelResourceLocation resourceLocation : locationsToReplace) {
            IBakedModel bakedModel = modelRegistry.getObject(resourceLocation);
            if (bakedModel instanceof OBJBakedModel) {
                Log.debug("Replacing " + resourceLocation);

                OBJBakedModel bakedAsObj = (OBJBakedModel) bakedModel;
                OBJModel obj = bakedAsObj.getModel();

                /*
                 * Set flip-v flag
                 */
                obj.customData.processUVData.put(OBJCustomData.Keys.FLIP_UVS, Pair.of(false, true));
                obj.customData.hasProcessed = true;
//              try {
//                  Object customData = customDataField.get(obj);
//                  customDataFlipVField.set(customData, true);
//              } catch (Exception e) {
//                  Log.error("Failed to adjust custom data. Inventory items will have wrong textures.", e);
//              }

                /*
                 * Create custom baked model as replacement
                 */

                bakedModel = new ItemAwareOBJBakedModel(bakedAsObj);
                modelRegistry.putObject(resourceLocation, bakedModel);
            }
        }

        //      if(Config.multipart_load) {
        //          MultipartHandlerClient.onModelBakeEvent(event);
        //      }

        Log.debug("Completed onModelBakeEvent");
    }
项目:CodeChickenLib    文件:ModelRegistryHelper.java   
/**
 * Called before CCL does anything to the ModelRegistry.
 * Useful for wrapped models, Use this in the constructor of the wrapped model.
 *
 * @param modelRegistry The Model registry.
 */
void onModelBakePre(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry);
项目:CodeChickenLib    文件:ModelRegistryHelper.java   
/**
 * A Simple callback for model baking.
 *
 * @param modelRegistry The Model registry.
 */
void onModelBake(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry);