use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class ModelBlockCustomCached method getModel.
@Override
protected IBakedModel getModel(IBlockState state) {
K key = getWorldKey(state);
IBakedModel model = worldCache.getIfPresent(key);
if (model == null) {
model = super.getModel(state);
worldCache.put(key, model);
}
return model;
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class ModelBlockCustomCached method getModel.
@Override
protected IBakedModel getModel(ItemStack stack, World world) {
K key = getInventoryKey(stack);
IBakedModel model = inventoryCache.getIfPresent(key);
if (model == null) {
model = bakeModel(stack, world, key);
inventoryCache.put(key, model);
}
return model;
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class ModelCrate method bakeModel.
/**
* Bake the crate model.
*/
private List<IBakedModel> bakeModel(ItemCrated crateItem) {
List<IBakedModel> models = new ArrayList<>();
ItemStack contained = crateItem.getContained();
if (!contained.isEmpty()) {
IBakedModel containedModel = getCustomContentModel(crateItem);
if (containedModel == null) {
containedModel = ModelUtil.getModel(contained);
}
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, 0.0625F, 0.5F));
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, -0.0625F, 0.5F));
}
return models;
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class ModelCamouflaged method addCamouflageModel.
private void addCamouflageModel(B block, IModelBaker baker, BlockRenderLayer layer, IBlockAccess world, BlockPos pos) {
if (world == null || pos == null) {
TextureAtlasSprite defaultSprite = block.getDefaultSprite();
baker.addBlockModel(pos, defaultSprite, DEFAULT_COLOR_INDEX);
baker.setParticleSprite(defaultSprite);
} else {
ItemStack camouflageStack = block.getCamouflageBlock(world, pos);
if (camouflageStack.isEmpty()) {
camouflageStack = GreenhouseController.createDefaultCamouflageBlock();
}
Block camouflageBlock = Block.getBlockFromItem(camouflageStack.getItem());
ICamouflageItemHandler itemHandler = CamouflageManager.camouflageAccess.getHandler(camouflageStack);
if (itemHandler != null) {
Pair<IBlockState, IBakedModel> modelPair = itemHandler.getModel(camouflageStack);
IBlockState blockState = modelPair.getLeft();
if (camouflageBlock.canRenderInLayer(blockState, layer)) {
IBakedModel bakedModel = modelPair.getRight();
baker.addBakedModel(blockState, bakedModel);
baker.setParticleSprite(bakedModel.getParticleTexture());
}
}
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class ModelCamouflaged method bakeBlock.
@Override
protected void bakeBlock(B block, Key key, IModelBaker baker, boolean inventory) {
IBlockAccess world = key.world;
BlockPos pos = key.pos;
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
if (layer != BlockRenderLayer.CUTOUT) {
addCamouflageModel(block, baker, layer, world, pos);
}
if (layer == BlockRenderLayer.CUTOUT || layer == null) {
IBakedModel model;
if (key.state != null) {
model = overlayModel.getModel(key.state);
} else {
model = overlayModel.getModel(key.itemStack, Minecraft.getMinecraft().world);
}
baker.addBakedModelPost(key.state, model);
}
}
Aggregations