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);
}
}
}
}
}
java类net.minecraft.client.renderer.block.model.ModelBlock的实例源码
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 27
收藏 0
点赞 0
评论 0
private void loadItemModels()
{
this.registerVariantNames();
for (Item item : Item.itemRegistry)
{
for (String s : this.getVariantNames(item))
{
ResourceLocation resourcelocation = this.getItemLocation(s);
this.itemLocations.put(s, resourcelocation);
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 item model: \'" + resourcelocation + "\' for item: \'" + Item.itemRegistry.getNameForObject(item) + "\'"), (Throwable)exception);
}
}
}
}
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
private IBakedModel bakeModel(ModelBlock modelBlockIn, ModelRotation modelRotationIn, boolean uvLocked)
{
TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName("particle")));
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)).setTexture(textureatlassprite);
for (BlockPart blockpart : modelBlockIn.getElements())
{
for (EnumFacing enumfacing : blockpart.mapFaces.keySet())
{
BlockPartFace blockpartface = (BlockPartFace)blockpart.mapFaces.get(enumfacing);
TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName(blockpartface.texture)));
if (blockpartface.cullFace == null)
{
simplebakedmodel$builder.addGeneralQuad(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
}
else
{
simplebakedmodel$builder.addFaceQuad(modelRotationIn.rotateFace(blockpartface.cullFace), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
}
}
}
return simplebakedmodel$builder.makeBakedModel();
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
private Set<ResourceLocation> getTextureLocations(ModelBlock p_177585_1_)
{
Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
for (BlockPart blockpart : p_177585_1_.getElements())
{
for (BlockPartFace blockpartface : blockpart.mapFaces.values())
{
ResourceLocation resourcelocation = new ResourceLocation(p_177585_1_.resolveTextureName(blockpartface.texture));
set.add(resourcelocation);
}
}
set.add(new ResourceLocation(p_177585_1_.resolveTextureName("particle")));
return set;
}
CustomItemProperties.java 文件源码
项目:BaseClient
阅读 23
收藏 0
点赞 0
评论 0
private static ModelBlock makeModelBlock(String[] p_makeModelBlock_0_)
{
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append("{\"parent\": \"builtin/generated\",\"textures\": {");
for (int i = 0; i < p_makeModelBlock_0_.length; ++i)
{
String s = p_makeModelBlock_0_[i];
if (i > 0)
{
stringbuffer.append(", ");
}
stringbuffer.append("\"layer" + i + "\": \"" + s + "\"");
}
stringbuffer.append("}}");
String s1 = stringbuffer.toString();
ModelBlock modelblock = ModelBlock.deserialize(s1);
return modelblock;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 24
收藏 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
阅读 25
收藏 0
点赞 0
评论 0
private void loadItemModels()
{
this.registerVariantNames();
for (Item item : Item.itemRegistry)
{
for (String s : this.getVariantNames(item))
{
ResourceLocation resourcelocation = this.getItemLocation(s);
this.itemLocations.put(s, resourcelocation);
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 item model: \'" + resourcelocation + "\' for item: \'" + Item.itemRegistry.getNameForObject(item) + "\'"), (Throwable)exception);
}
}
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 21
收藏 0
点赞 0
评论 0
private IBakedModel bakeModel(ModelBlock modelBlockIn, ModelRotation modelRotationIn, boolean uvLocked)
{
TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName("particle")));
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)).setTexture(textureatlassprite);
for (BlockPart blockpart : modelBlockIn.getElements())
{
for (EnumFacing enumfacing : blockpart.mapFaces.keySet())
{
BlockPartFace blockpartface = (BlockPartFace)blockpart.mapFaces.get(enumfacing);
TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName(blockpartface.texture)));
if (blockpartface.cullFace == null)
{
simplebakedmodel$builder.addGeneralQuad(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
}
else
{
simplebakedmodel$builder.addFaceQuad(modelRotationIn.rotateFace(blockpartface.cullFace), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
}
}
}
return simplebakedmodel$builder.makeBakedModel();
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 24
收藏 0
点赞 0
评论 0
private Set<ResourceLocation> getTextureLocations(ModelBlock p_177585_1_)
{
Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
for (BlockPart blockpart : p_177585_1_.getElements())
{
for (BlockPartFace blockpartface : blockpart.mapFaces.values())
{
ResourceLocation resourcelocation = new ResourceLocation(p_177585_1_.resolveTextureName(blockpartface.texture));
set.add(resourcelocation);
}
}
set.add(new ResourceLocation(p_177585_1_.resolveTextureName("particle")));
return set;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 35
收藏 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
阅读 20
收藏 0
点赞 0
评论 0
private void loadItemModels()
{
this.registerVariantNames();
for (Item item : Item.itemRegistry)
{
for (String s : this.getVariantNames(item))
{
ResourceLocation resourcelocation = this.getItemLocation(s);
this.itemLocations.put(s, resourcelocation);
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 item model: \'" + resourcelocation + "\' for item: \'" + Item.itemRegistry.getNameForObject(item) + "\'"), (Throwable)exception);
}
}
}
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 46
收藏 0
点赞 0
评论 0
private IBakedModel bakeModel(ModelBlock modelBlockIn, ModelRotation modelRotationIn, boolean uvLocked)
{
TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName("particle")));
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)).setTexture(textureatlassprite);
for (BlockPart blockpart : modelBlockIn.getElements())
{
for (EnumFacing enumfacing : blockpart.mapFaces.keySet())
{
BlockPartFace blockpartface = (BlockPartFace)blockpart.mapFaces.get(enumfacing);
TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName(blockpartface.texture)));
if (blockpartface.cullFace == null)
{
simplebakedmodel$builder.addGeneralQuad(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
}
else
{
simplebakedmodel$builder.addFaceQuad(modelRotationIn.rotateFace(blockpartface.cullFace), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
}
}
}
return simplebakedmodel$builder.makeBakedModel();
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
private Set<ResourceLocation> getTextureLocations(ModelBlock p_177585_1_)
{
Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
for (BlockPart blockpart : p_177585_1_.getElements())
{
for (BlockPartFace blockpartface : blockpart.mapFaces.values())
{
ResourceLocation resourcelocation = new ResourceLocation(p_177585_1_.resolveTextureName(blockpartface.texture));
set.add(resourcelocation);
}
}
set.add(new ResourceLocation(p_177585_1_.resolveTextureName("particle")));
return set;
}
CustomItemProperties.java 文件源码
项目:Backmemed
阅读 19
收藏 0
点赞 0
评论 0
private static ModelBlock makeModelBlock(String[] p_makeModelBlock_0_)
{
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append("{\"parent\": \"builtin/generated\",\"textures\": {");
for (int i = 0; i < p_makeModelBlock_0_.length; ++i)
{
String s = p_makeModelBlock_0_[i];
if (i > 0)
{
stringbuffer.append(", ");
}
stringbuffer.append("\"layer" + i + "\": \"" + s + "\"");
}
stringbuffer.append("}}");
String s1 = stringbuffer.toString();
ModelBlock modelblock = ModelBlock.deserialize(s1);
return modelblock;
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 23
收藏 0
点赞 0
评论 0
public IModel loadModel(ResourceLocation modelLocation) throws Exception
{
if(modelLocation.equals(MODEL_MISSING) && loader.missingModel != null)
{
return loader.getMissingModel();
}
String modelPath = modelLocation.getResourcePath();
if(modelLocation.getResourcePath().startsWith("models/"))
{
modelPath = modelPath.substring("models/".length());
}
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getResourceDomain(), "armatures/" + modelPath + ".json");
ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(loader.resourceManager, armatureLocation);
ModelBlock model = loader.loadModel(modelLocation);
IModel iModel = loader.new VanillaModelWrapper(modelLocation, model, false, animation);
if(loader.missingModel == null && modelLocation.equals(MODEL_MISSING))
{
loader.missingModel = iModel;
}
return iModel;
}
WoodType.java 文件源码
项目:Alchemy
阅读 21
收藏 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;
}
}
WoodType.java 文件源码
项目:Alchemy
阅读 21
收藏 0
点赞 0
评论 0
@Nullable
@SideOnly(Side.CLIENT)
public static String getTexture(ModelBlock modelBlock) {
if (modelBlock == null)
return null;
if (modelBlock.textures == null)
return getTexture(modelBlock.parent);
String texture = modelBlock.textures.get("all");
if (texture != null)
return texture;
texture = modelBlock.textures.get("side");
if (texture != null)
return texture;
texture = modelBlock.textures.get("particle");
if (texture != null)
return texture;
for (Entry<String, String> entry : modelBlock.textures.entrySet())
if (!entry.getKey().equals("end") && !entry.getValue().contains("_top") && !entry.getValue().contains("top_"))
return entry.getValue();
return getTexture(modelBlock.parent);
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 26
收藏 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 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
private void loadModelsCheck()
{
this.loadModels();
for (ModelBlock modelblock : this.models.values())
{
modelblock.getParentFromMap(this.models);
}
ModelBlock.checkModelHierarchy(this.models);
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 26
收藏 0
点赞 0
评论 0
private ResourceLocation getParentLocation(ResourceLocation p_177576_1_)
{
for (Entry<ResourceLocation, ModelBlock> entry : this.models.entrySet())
{
ModelBlock modelblock = (ModelBlock)entry.getValue();
if (modelblock != null && p_177576_1_.equals(modelblock.getParentLocation()))
{
return (ResourceLocation)entry.getKey();
}
}
return null;
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
private boolean hasItemModel(ModelBlock p_177581_1_)
{
if (p_177581_1_ == null)
{
return false;
}
else
{
ModelBlock modelblock = p_177581_1_.getRootModel();
return modelblock == MODEL_GENERATED || modelblock == MODEL_COMPASS || modelblock == MODEL_CLOCK;
}
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
private boolean isCustomRenderer(ModelBlock p_177587_1_)
{
if (p_177587_1_ == null)
{
return false;
}
else
{
ModelBlock modelblock = p_177587_1_.getRootModel();
return modelblock == MODEL_ENTITY;
}
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 24
收藏 0
点赞 0
评论 0
private void bakeItemModels()
{
for (ResourceLocation resourcelocation : this.itemLocations.values())
{
ModelBlock modelblock = (ModelBlock)this.models.get(resourcelocation);
if (this.hasItemModel(modelblock))
{
ModelBlock modelblock1 = this.makeItemModel(modelblock);
if (modelblock1 != null)
{
modelblock1.name = resourcelocation.toString();
}
this.models.put(resourcelocation, modelblock1);
}
else if (this.isCustomRenderer(modelblock))
{
this.models.put(resourcelocation, modelblock);
}
}
for (TextureAtlasSprite textureatlassprite : this.sprites.values())
{
if (!textureatlassprite.hasAnimationMetadata())
{
textureatlassprite.clearFramesTextureData();
}
}
}
CustomItemProperties.java 文件源码
项目:BaseClient
阅读 24
收藏 0
点赞 0
评论 0
private static IBakedModel makeBakedModel(TextureMap p_makeBakedModel_0_, ItemModelGenerator p_makeBakedModel_1_, String[] p_makeBakedModel_2_, boolean p_makeBakedModel_3_)
{
ModelBlock modelblock = makeModelBlock(p_makeBakedModel_2_);
ModelBlock modelblock1 = p_makeBakedModel_1_.makeItemModel(p_makeBakedModel_0_, modelblock);
IBakedModel ibakedmodel = bakeModel(p_makeBakedModel_0_, modelblock1, p_makeBakedModel_3_);
return ibakedmodel;
}
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;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 26
收藏 0
点赞 0
评论 0
private void loadModelsCheck()
{
this.loadModels();
for (ModelBlock modelblock : this.models.values())
{
modelblock.getParentFromMap(this.models);
}
ModelBlock.checkModelHierarchy(this.models);
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 25
收藏 0
点赞 0
评论 0
private ResourceLocation getParentLocation(ResourceLocation p_177576_1_)
{
for (Entry<ResourceLocation, ModelBlock> entry : this.models.entrySet())
{
ModelBlock modelblock = (ModelBlock)entry.getValue();
if (modelblock != null && p_177576_1_.equals(modelblock.getParentLocation()))
{
return (ResourceLocation)entry.getKey();
}
}
return null;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
private boolean hasItemModel(ModelBlock p_177581_1_)
{
if (p_177581_1_ == null)
{
return false;
}
else
{
ModelBlock modelblock = p_177581_1_.getRootModel();
return modelblock == MODEL_GENERATED || modelblock == MODEL_COMPASS || modelblock == MODEL_CLOCK;
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 23
收藏 0
点赞 0
评论 0
private boolean isCustomRenderer(ModelBlock p_177587_1_)
{
if (p_177587_1_ == null)
{
return false;
}
else
{
ModelBlock modelblock = p_177587_1_.getRootModel();
return modelblock == MODEL_ENTITY;
}
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 24
收藏 0
点赞 0
评论 0
private void bakeItemModels()
{
for (ResourceLocation resourcelocation : this.itemLocations.values())
{
ModelBlock modelblock = (ModelBlock)this.models.get(resourcelocation);
if (this.hasItemModel(modelblock))
{
ModelBlock modelblock1 = this.makeItemModel(modelblock);
if (modelblock1 != null)
{
modelblock1.name = resourcelocation.toString();
}
this.models.put(resourcelocation, modelblock1);
}
else if (this.isCustomRenderer(modelblock))
{
this.models.put(resourcelocation, modelblock);
}
}
for (TextureAtlasSprite textureatlassprite : this.sprites.values())
{
if (!textureatlassprite.hasAnimationMetadata())
{
textureatlassprite.clearFramesTextureData();
}
}
}