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);
}
}
}
java类net.minecraft.client.renderer.block.model.ModelBlockDefinition的实例源码
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 19
收藏 0
点赞 0
评论 0
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);
}
}
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
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);
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 17
收藏 0
点赞 0
评论 0
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);
}
}
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
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);
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 21
收藏 0
点赞 0
评论 0
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);
}
}
}
}
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 61
收藏 0
点赞 0
评论 0
@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;
}
}
WoodType.java 文件源码
项目:Alchemy
阅读 26
收藏 0
点赞 0
评论 0
@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;
}
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 17
收藏 0
点赞 0
评论 0
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();
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 16
收藏 0
点赞 0
评论 0
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;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 26
收藏 0
点赞 0
评论 0
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();
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 18
收藏 0
点赞 0
评论 0
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;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
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();
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 23
收藏 0
点赞 0
评论 0
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;
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 23
收藏 0
点赞 0
评论 0
@Override
protected void registerMultipartVariant(ModelBlockDefinition definition, Collection<ModelResourceLocation> locations)
{
for (ModelResourceLocation location : locations)
{
registerVariant(null, location);
}
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 28
收藏 0
点赞 0
评论 0
@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>());
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
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()));
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 20
收藏 0
点赞 0
评论 0
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);
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
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()));
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 21
收藏 0
点赞 0
评论 0
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);
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
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()));
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
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);
}
}
}