Jump to content

Rendering a set of AxisAlignedBB with textures with TESR


Recommended Posts

Hey guys,


I am fairly new to modding and at the moment, I am trying to make the 'chisel and bits' mod, as kind of a challenge. So, I have done quite a lot already, what I now need to do is render every part of the chiseled block with the correct texture. the problem is that I have no idea what the best way is to render blocks, with the only information being the AxisAlignedBB's and the textures for each component of the block. I thought a TESR would be a good idea, so this is my TESR class as far as it is now in which I just tried to render a model which wasn't registered yet:

package com.extraBlocks.block.miniBlock;

import java.util.List;

import org.lwjgl.opengl.GL11;

import com.extraBlocks.Main;
import com.extraBlocks.item.ModItems;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.block.model.ModelManager;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;

public class TESRMiniBlock extends TileEntitySpecialRenderer<TileEntityMiniBlock> {

	TileEntityMiniBlock te = null;

	public void render(TileEntityMiniBlock te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
		renderBlock(te, x, y, z, partialTicks, destroyStage, alpha);

	public void renderBlock(TileEntityMiniBlock te1, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
		te = (TileEntityMiniBlock) Minecraft.getMinecraft().getIntegratedServer().getWorld(Minecraft.getMinecraft().world.provider.getDimension()).getTileEntity(te1.getPos());

		ItemStack stack = te.inventory.getStackInSlot(0);
		if (!stack.isEmpty()) {
			BlockRendererDispatcher r = Minecraft.getMinecraft().getBlockRendererDispatcher();
			Tessellator tes = Tessellator.getInstance();

			GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1f);
			GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
			GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5);
			IBakedModel model0 = null;
			try {
//				model0 = ModelLoaderRegistry.getModel(new ResourceLocation(Main.MODID, "block/tinyblock"));
				model0 = r.getBlockModelShapes().getModelManager().getModel(new ModelResourceLocation(Main.MODID + ":blocks/shadow_ore", "normal"));
			} catch (Exception e) {
				// TODO Auto-generated catch block
			if(model0 != null) {
				r.getBlockModelRenderer().renderModelBrightnessColor(model0, 1.0F, 1.0F, 1.0F, 1.0F);
			Minecraft.getMinecraft().getRenderItem().renderItem(stack, model0);

Now, as you can probably tell, I don't quit know how to do this, so any help is greatly appreciated.

Link to comment
Share on other sites

9 hours ago, Lenardjee said:

kind of a challenge

No, it's a really big challenge.

I've tried that concept as well in Minecraft 1.6.4, also using a TESR. Every time the Block was in view, there would be massive FPS drops because it had to render 16*16*16=4096 cubes. Using an IBakedModel (ISBRH back then) would cause massive FPS drops every time the block got updated.


AlgorithmX2 has done a lot of optimalizations to make it able to render without any major FPS issues, including coremodding.


You should try doing something more simple first. This idea might seem simple, but it it's really hard to implement in a usable way.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.


1.12 -> 1.13 primer by williewillus.


1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.



Link to comment
Share on other sites

I know that it is a big project, but I have done all the hard work already. I have everything set up to make the parts of the block using AxisAlignedBB's and the only thing I have left to do is to display the block. The problem is: I don't know how to use IBakedModel (neither do I know if I should even be using it). And:

1 hour ago, larsgerrits said:

AlgorithmX2 has done a lot of optimalizations to make it able to render without any major FPS issues, including coremodding.

does that mean that using IBakedModel for this is not a problem now?


Furthermore, how do I update the block model while the game is running? How would that work without having to reload the texturepacks everytime I make a change to the model?


I can do make mods of some types, but there are parts in forge modding that I just don't quite get yet.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.