Java 类net.minecraft.client.renderer.block.model.ModelBlockDefinition 实例源码

项目:DecompiledMinecraft    文件:ModelBakery.java   
private void loadVariants(Collection<ModelResourceLocation> p_177591_1_)
{
    for (ModelResourceLocation modelresourcelocation : p_177591_1_)
    {
        try
        {
            ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(modelresourcelocation);

            try
            {
                this.registerVariant(modelblockdefinition, modelresourcelocation);
            }
            catch (Exception var6)
            {
                LOGGER.warn("Unable to load variant: " + modelresourcelocation.getVariant() + " from " + modelresourcelocation);
            }
        }
        catch (Exception exception)
        {
            LOGGER.warn((String)("Unable to load definition " + modelresourcelocation), (Throwable)exception);
        }
    }
}
项目:DecompiledMinecraft    文件:ModelBakery.java   
private void loadVariantModels()
{
    for (ModelResourceLocation modelresourcelocation : this.variants.keySet())
    {
        for (ModelBlockDefinition.Variant modelblockdefinition$variant : ((ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation)).getVariants())
        {
            ResourceLocation resourcelocation = modelblockdefinition$variant.getModelLocation();

            if (this.models.get(resourcelocation) == null)
            {
                try
                {
                    ModelBlock modelblock = this.loadModel(resourcelocation);
                    this.models.put(resourcelocation, modelblock);
                }
                catch (Exception exception)
                {
                    LOGGER.warn((String)("Unable to load block model: \'" + resourcelocation + "\' for variant: \'" + modelresourcelocation + "\'"), (Throwable)exception);
                }
            }
        }
    }
}
项目:BaseClient    文件:ModelBakery.java   
private void loadVariants(Collection<ModelResourceLocation> p_177591_1_)
{
    for (ModelResourceLocation modelresourcelocation : p_177591_1_)
    {
        try
        {
            ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(modelresourcelocation);

            try
            {
                this.registerVariant(modelblockdefinition, modelresourcelocation);
            }
            catch (Exception var6)
            {
                LOGGER.warn("Unable to load variant: " + modelresourcelocation.getVariant() + " from " + modelresourcelocation);
            }
        }
        catch (Exception exception)
        {
            LOGGER.warn((String)("Unable to load definition " + modelresourcelocation), (Throwable)exception);
        }
    }
}
项目:BaseClient    文件:ModelBakery.java   
private void loadVariantModels()
{
    for (ModelResourceLocation modelresourcelocation : this.variants.keySet())
    {
        for (ModelBlockDefinition.Variant modelblockdefinition$variant : ((ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation)).getVariants())
        {
            ResourceLocation resourcelocation = modelblockdefinition$variant.getModelLocation();

            if (this.models.get(resourcelocation) == null)
            {
                try
                {
                    ModelBlock modelblock = this.loadModel(resourcelocation);
                    this.models.put(resourcelocation, modelblock);
                }
                catch (Exception exception)
                {
                    LOGGER.warn((String)("Unable to load block model: \'" + resourcelocation + "\' for variant: \'" + modelresourcelocation + "\'"), (Throwable)exception);
                }
            }
        }
    }
}
项目:BaseClient    文件:ModelBakery.java   
private void loadVariants(Collection<ModelResourceLocation> p_177591_1_)
{
    for (ModelResourceLocation modelresourcelocation : p_177591_1_)
    {
        try
        {
            ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(modelresourcelocation);

            try
            {
                this.registerVariant(modelblockdefinition, modelresourcelocation);
            }
            catch (Exception var6)
            {
                LOGGER.warn("Unable to load variant: " + modelresourcelocation.getVariant() + " from " + modelresourcelocation);
            }
        }
        catch (Exception exception)
        {
            LOGGER.warn((String)("Unable to load definition " + modelresourcelocation), (Throwable)exception);
        }
    }
}
项目:BaseClient    文件:ModelBakery.java   
private void loadVariantModels()
{
    for (ModelResourceLocation modelresourcelocation : this.variants.keySet())
    {
        for (ModelBlockDefinition.Variant modelblockdefinition$variant : ((ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation)).getVariants())
        {
            ResourceLocation resourcelocation = modelblockdefinition$variant.getModelLocation();

            if (this.models.get(resourcelocation) == null)
            {
                try
                {
                    ModelBlock modelblock = this.loadModel(resourcelocation);
                    this.models.put(resourcelocation, modelblock);
                }
                catch (Exception exception)
                {
                    LOGGER.warn((String)("Unable to load block model: \'" + resourcelocation + "\' for variant: \'" + modelresourcelocation + "\'"), (Throwable)exception);
                }
            }
        }
    }
}
项目:CustomWorldGen    文件:ModelLoader.java   
@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception
{
    ModelResourceLocation variant = (ModelResourceLocation) modelLocation;
    ModelBlockDefinition definition = loader.getModelBlockDefinition(variant);
    try
    {
        VariantList variants = definition.getVariant(variant.getVariant());
        return new WeightedRandomModel(variant, variants);
    }
    catch(MissingVariantException e)
    {
        if(definition.hasMultipartData())
        {
            return new MultipartModel(new ResourceLocation(variant.getResourceDomain(), variant.getResourcePath()), definition.getMultipartData());
        }
        throw e;
    }
}
项目:Alchemy    文件:WoodType.java   
@SideOnly(Side.CLIENT)
public static String getTexture(IBlockState state, String defaultTexture) {
    try {
        ModelLoader loader = ModelLoader.VanillaLoader.INSTANCE.getLoader();
        BlockStateMapper mapper = loader.blockModelShapes.getBlockStateMapper();
        Map<IBlockState, ModelResourceLocation> map = mapper.getVariants(state.getBlock());
        ModelResourceLocation stateLocation = map.get(state);
        ModelBlockDefinition definition = loader.getModelBlockDefinition(stateLocation);
        ResourceLocation modelLocation = definition.getVariant(stateLocation.getVariant()).getVariantList().get(0).getModelLocation();
        ModelBlock modelBlock = loader.loadModel(
                new ResourceLocation(modelLocation.getResourceDomain(), "models/" + modelLocation.getResourcePath()));
        String texture = getTexture(modelBlock);
        return ObjectUtils.firstNonNull(texture, defaultTexture);
    } catch (Exception e) {
        e.printStackTrace();
        return defaultTexture;
    }
}
项目:DecompiledMinecraft    文件:ModelBakery.java   
private void loadVariantItemModels()
{
    this.loadVariants(this.blockModelShapes.getBlockStateMapper().putAllStateModelLocations().values());
    this.variants.put(MODEL_MISSING, new ModelBlockDefinition.Variants(MODEL_MISSING.getVariant(), Lists.newArrayList(new ModelBlockDefinition.Variant[] {new ModelBlockDefinition.Variant(new ResourceLocation(MODEL_MISSING.getResourcePath()), ModelRotation.X0_Y0, false, 1)})));
    ResourceLocation resourcelocation = new ResourceLocation("item_frame");
    ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(resourcelocation);
    this.registerVariant(modelblockdefinition, new ModelResourceLocation(resourcelocation, "normal"));
    this.registerVariant(modelblockdefinition, new ModelResourceLocation(resourcelocation, "map"));
    this.loadVariantModels();
    this.loadItemModels();
}
项目:DecompiledMinecraft    文件:ModelBakery.java   
private Set<ResourceLocation> getVariantsTextureLocations()
{
    Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
    List<ModelResourceLocation> list = Lists.newArrayList(this.variants.keySet());
    Collections.sort(list, new Comparator<ModelResourceLocation>()
    {
        public int compare(ModelResourceLocation p_compare_1_, ModelResourceLocation p_compare_2_)
        {
            return p_compare_1_.toString().compareTo(p_compare_2_.toString());
        }
    });

    for (ModelResourceLocation modelresourcelocation : list)
    {
        ModelBlockDefinition.Variants modelblockdefinition$variants = (ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation);

        for (ModelBlockDefinition.Variant modelblockdefinition$variant : modelblockdefinition$variants.getVariants())
        {
            ModelBlock modelblock = (ModelBlock)this.models.get(modelblockdefinition$variant.getModelLocation());

            if (modelblock == null)
            {
                LOGGER.warn("Missing model for: " + modelresourcelocation);
            }
            else
            {
                set.addAll(this.getTextureLocations(modelblock));
            }
        }
    }

    set.addAll(LOCATIONS_BUILTIN_TEXTURES);
    return set;
}
项目:BaseClient    文件:ModelBakery.java   
private void loadVariantItemModels()
{
    this.loadVariants(this.blockModelShapes.getBlockStateMapper().putAllStateModelLocations().values());
    this.variants.put(MODEL_MISSING, new ModelBlockDefinition.Variants(MODEL_MISSING.getVariant(), Lists.newArrayList(new ModelBlockDefinition.Variant[] {new ModelBlockDefinition.Variant(new ResourceLocation(MODEL_MISSING.getResourcePath()), ModelRotation.X0_Y0, false, 1)})));
    ResourceLocation resourcelocation = new ResourceLocation("item_frame");
    ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(resourcelocation);
    this.registerVariant(modelblockdefinition, new ModelResourceLocation(resourcelocation, "normal"));
    this.registerVariant(modelblockdefinition, new ModelResourceLocation(resourcelocation, "map"));
    this.loadVariantModels();
    this.loadItemModels();
}
项目:BaseClient    文件:ModelBakery.java   
private Set<ResourceLocation> getVariantsTextureLocations()
{
    Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
    List<ModelResourceLocation> list = Lists.newArrayList(this.variants.keySet());
    Collections.sort(list, new Comparator<ModelResourceLocation>()
    {
        public int compare(ModelResourceLocation p_compare_1_, ModelResourceLocation p_compare_2_)
        {
            return p_compare_1_.toString().compareTo(p_compare_2_.toString());
        }
    });

    for (ModelResourceLocation modelresourcelocation : list)
    {
        ModelBlockDefinition.Variants modelblockdefinition$variants = (ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation);

        for (ModelBlockDefinition.Variant modelblockdefinition$variant : modelblockdefinition$variants.getVariants())
        {
            ModelBlock modelblock = (ModelBlock)this.models.get(modelblockdefinition$variant.getModelLocation());

            if (modelblock == null)
            {
                LOGGER.warn("Missing model for: " + modelresourcelocation);
            }
            else
            {
                set.addAll(this.getTextureLocations(modelblock));
            }
        }
    }

    set.addAll(LOCATIONS_BUILTIN_TEXTURES);
    return set;
}
项目:BaseClient    文件:ModelBakery.java   
private void loadVariantItemModels()
{
    this.loadVariants(this.blockModelShapes.getBlockStateMapper().putAllStateModelLocations().values());
    this.variants.put(MODEL_MISSING, new ModelBlockDefinition.Variants(MODEL_MISSING.getVariant(), Lists.newArrayList(new ModelBlockDefinition.Variant[] {new ModelBlockDefinition.Variant(new ResourceLocation(MODEL_MISSING.getResourcePath()), ModelRotation.X0_Y0, false, 1)})));
    ResourceLocation resourcelocation = new ResourceLocation("item_frame");
    ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(resourcelocation);
    this.registerVariant(modelblockdefinition, new ModelResourceLocation(resourcelocation, "normal"));
    this.registerVariant(modelblockdefinition, new ModelResourceLocation(resourcelocation, "map"));
    this.loadVariantModels();
    this.loadItemModels();
}
项目:BaseClient    文件:ModelBakery.java   
private Set<ResourceLocation> getVariantsTextureLocations()
{
    Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
    List<ModelResourceLocation> list = Lists.newArrayList(this.variants.keySet());
    Collections.sort(list, new Comparator<ModelResourceLocation>()
    {
        public int compare(ModelResourceLocation p_compare_1_, ModelResourceLocation p_compare_2_)
        {
            return p_compare_1_.toString().compareTo(p_compare_2_.toString());
        }
    });

    for (ModelResourceLocation modelresourcelocation : list)
    {
        ModelBlockDefinition.Variants modelblockdefinition$variants = (ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation);

        for (ModelBlockDefinition.Variant modelblockdefinition$variant : modelblockdefinition$variants.getVariants())
        {
            ModelBlock modelblock = (ModelBlock)this.models.get(modelblockdefinition$variant.getModelLocation());

            if (modelblock == null)
            {
                LOGGER.warn("Missing model for: " + modelresourcelocation);
            }
            else
            {
                set.addAll(this.getTextureLocations(modelblock));
            }
        }
    }

    set.addAll(LOCATIONS_BUILTIN_TEXTURES);
    return set;
}
项目:CustomWorldGen    文件:ModelLoader.java   
@Override
protected void registerVariant(ModelBlockDefinition definition, ModelResourceLocation location)
{
    IModel model;
    try
    {
        model = ModelLoaderRegistry.getModel(location);
    }
    catch(Exception e)
    {
        storeException(location, e);
        model = getMissingModel();
    }
    stateModels.put(location, model);
}
项目:CustomWorldGen    文件:ModelLoader.java   
@Override
protected void registerMultipartVariant(ModelBlockDefinition definition, Collection<ModelResourceLocation> locations)
{
    for (ModelResourceLocation location : locations)
    {
        registerVariant(null, location);
    }
}
项目:CustomWorldGen    文件:ModelLoader.java   
@Override
protected ModelBlockDefinition getModelBlockDefinition(ResourceLocation location)
{
    try
    {
        return super.getModelBlockDefinition(location);
    }
    catch (Exception exception)
    {
        storeException(location, new Exception("Could not load model definition for variant " + location, exception));
    }
    return new ModelBlockDefinition(new ArrayList<ModelBlockDefinition>());
}
项目:DecompiledMinecraft    文件:ModelBakery.java   
private void registerVariant(ModelBlockDefinition p_177569_1_, ModelResourceLocation p_177569_2_)
{
    this.variants.put(p_177569_2_, p_177569_1_.getVariants(p_177569_2_.getVariant()));
}
项目:DecompiledMinecraft    文件:ModelBakery.java   
private void bakeBlockModels()
{
    for (ModelResourceLocation modelresourcelocation : this.variants.keySet())
    {
        WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder();
        int i = 0;

        for (ModelBlockDefinition.Variant modelblockdefinition$variant : ((ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation)).getVariants())
        {
            ModelBlock modelblock = (ModelBlock)this.models.get(modelblockdefinition$variant.getModelLocation());

            if (modelblock != null && modelblock.isResolved())
            {
                ++i;
                weightedbakedmodel$builder.add(this.bakeModel(modelblock, modelblockdefinition$variant.getRotation(), modelblockdefinition$variant.isUvLocked()), modelblockdefinition$variant.getWeight());
            }
            else
            {
                LOGGER.warn("Missing model for: " + modelresourcelocation);
            }
        }

        if (i == 0)
        {
            LOGGER.warn("No weighted models for: " + modelresourcelocation);
        }
        else if (i == 1)
        {
            this.bakedRegistry.putObject(modelresourcelocation, weightedbakedmodel$builder.first());
        }
        else
        {
            this.bakedRegistry.putObject(modelresourcelocation, weightedbakedmodel$builder.build());
        }
    }

    for (Entry<String, ResourceLocation> entry : this.itemLocations.entrySet())
    {
        ResourceLocation resourcelocation = (ResourceLocation)entry.getValue();
        ModelResourceLocation modelresourcelocation1 = new ModelResourceLocation((String)entry.getKey(), "inventory");
        ModelBlock modelblock1 = (ModelBlock)this.models.get(resourcelocation);

        if (modelblock1 != null && modelblock1.isResolved())
        {
            if (this.isCustomRenderer(modelblock1))
            {
                this.bakedRegistry.putObject(modelresourcelocation1, new BuiltInModel(modelblock1.func_181682_g()));
            }
            else
            {
                this.bakedRegistry.putObject(modelresourcelocation1, this.bakeModel(modelblock1, ModelRotation.X0_Y0, false));
            }
        }
        else
        {
            LOGGER.warn("Missing model for: " + resourcelocation);
        }
    }
}
项目:BaseClient    文件:ModelBakery.java   
private void registerVariant(ModelBlockDefinition p_177569_1_, ModelResourceLocation p_177569_2_)
{
    this.variants.put(p_177569_2_, p_177569_1_.getVariants(p_177569_2_.getVariant()));
}
项目:BaseClient    文件:ModelBakery.java   
private void bakeBlockModels()
{
    for (ModelResourceLocation modelresourcelocation : this.variants.keySet())
    {
        WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder();
        int i = 0;

        for (ModelBlockDefinition.Variant modelblockdefinition$variant : ((ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation)).getVariants())
        {
            ModelBlock modelblock = (ModelBlock)this.models.get(modelblockdefinition$variant.getModelLocation());

            if (modelblock != null && modelblock.isResolved())
            {
                ++i;
                weightedbakedmodel$builder.add(this.bakeModel(modelblock, modelblockdefinition$variant.getRotation(), modelblockdefinition$variant.isUvLocked()), modelblockdefinition$variant.getWeight());
            }
            else
            {
                LOGGER.warn("Missing model for: " + modelresourcelocation);
            }
        }

        if (i == 0)
        {
            LOGGER.warn("No weighted models for: " + modelresourcelocation);
        }
        else if (i == 1)
        {
            this.bakedRegistry.putObject(modelresourcelocation, weightedbakedmodel$builder.first());
        }
        else
        {
            this.bakedRegistry.putObject(modelresourcelocation, weightedbakedmodel$builder.build());
        }
    }

    for (Entry<String, ResourceLocation> entry : this.itemLocations.entrySet())
    {
        ResourceLocation resourcelocation = (ResourceLocation)entry.getValue();
        ModelResourceLocation modelresourcelocation1 = new ModelResourceLocation((String)entry.getKey(), "inventory");
        ModelBlock modelblock1 = (ModelBlock)this.models.get(resourcelocation);

        if (modelblock1 != null && modelblock1.isResolved())
        {
            if (this.isCustomRenderer(modelblock1))
            {
                this.bakedRegistry.putObject(modelresourcelocation1, new BuiltInModel(modelblock1.func_181682_g()));
            }
            else
            {
                this.bakedRegistry.putObject(modelresourcelocation1, this.bakeModel(modelblock1, ModelRotation.X0_Y0, false));
            }
        }
        else
        {
            LOGGER.warn("Missing model for: " + resourcelocation);
        }
    }
}
项目:BaseClient    文件:ModelBakery.java   
private void registerVariant(ModelBlockDefinition p_177569_1_, ModelResourceLocation p_177569_2_)
{
    this.variants.put(p_177569_2_, p_177569_1_.getVariants(p_177569_2_.getVariant()));
}
项目:BaseClient    文件:ModelBakery.java   
private void bakeBlockModels()
{
    for (ModelResourceLocation modelresourcelocation : this.variants.keySet())
    {
        WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder();
        int i = 0;

        for (ModelBlockDefinition.Variant modelblockdefinition$variant : ((ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation)).getVariants())
        {
            ModelBlock modelblock = (ModelBlock)this.models.get(modelblockdefinition$variant.getModelLocation());

            if (modelblock != null && modelblock.isResolved())
            {
                ++i;
                weightedbakedmodel$builder.add(this.bakeModel(modelblock, modelblockdefinition$variant.getRotation(), modelblockdefinition$variant.isUvLocked()), modelblockdefinition$variant.getWeight());
            }
            else
            {
                LOGGER.warn("Missing model for: " + modelresourcelocation);
            }
        }

        if (i == 0)
        {
            LOGGER.warn("No weighted models for: " + modelresourcelocation);
        }
        else if (i == 1)
        {
            this.bakedRegistry.putObject(modelresourcelocation, weightedbakedmodel$builder.first());
        }
        else
        {
            this.bakedRegistry.putObject(modelresourcelocation, weightedbakedmodel$builder.build());
        }
    }

    for (Entry<String, ResourceLocation> entry : this.itemLocations.entrySet())
    {
        ResourceLocation resourcelocation = (ResourceLocation)entry.getValue();
        ModelResourceLocation modelresourcelocation1 = new ModelResourceLocation((String)entry.getKey(), "inventory");
        ModelBlock modelblock1 = (ModelBlock)this.models.get(resourcelocation);

        if (modelblock1 != null && modelblock1.isResolved())
        {
            if (this.isCustomRenderer(modelblock1))
            {
                this.bakedRegistry.putObject(modelresourcelocation1, new BuiltInModel(modelblock1.func_181682_g()));
            }
            else
            {
                this.bakedRegistry.putObject(modelresourcelocation1, this.bakeModel(modelblock1, ModelRotation.X0_Y0, false));
            }
        }
        else
        {
            LOGGER.warn("Missing model for: " + resourcelocation);
        }
    }
}