Jump to content

Recommended Posts

Posted

Hello everyone,

I am trying to make a tile entity special renderer that renders a json model that is not used by a block or an item. I've looked at the RendererItemFrame class, and there this thing:
 

ibakedmodel = modelmanager.getModel(this.itemFrameModel);

 

I've tried but it didn't work, I'm guessing you have to register the model first. My question is, how to do that? If it's not possible that way, how should I do that?
Here is my code:
 

@SideOnly(Side.CLIENT)
public class TileEntityWorkBenchRenderer extends TileEntitySpecialRenderer<TileEntityWorkBench>{
	
	public final Minecraft mc = Minecraft.getMinecraft();
	
	
	@Override
	public void renderTileEntityAt(TileEntityWorkBench te, double x, double y, double z, float partialTicks, int destroyStage){
        try{
        	
            this.mc.getRenderManager().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
            ModelManager modelmanager = blockrendererdispatcher.getBlockModelShapes().getModelManager();
            IBakedModel ibakedmodel;
			
	        GlStateManager.pushMatrix();
	        
	        GlStateManager.translate(x + 0.5D, y + 1D, z + 0.5D);
	        
	        ibakedmodel = modelmanager.getModel(new ModelResourceLocation(Reference.MOD_ID + ":workbench", "text"));
	
	        GlStateManager.pushMatrix();
	        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
	
	        blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F);
	
	        GlStateManager.popMatrix();
	        GlStateManager.translate(0.0F, 0.0F, 0.4375F);
	        GlStateManager.popMatrix();
        }catch(Exception e){
        	e.printStackTrace();
        }
	}
}

The blockstate file:
 

{
    "variants": {
        "normal": { "model": "modtest:workbench" },
        "text": { "model": "modtest:workbench_text" }
    }
}

I've tried to load a model that is used by a block and it works

ibakedmodel = modelmanager.getModel(new ModelResourceLocation(Reference.MOD_ID + ":workbench", "normal"));

Note that I'm still new to modding and that I have no idea if I'm going for the right way.

Thanks! 

Posted

Well I was planning on using a TESR to render a custom model that would be rotating on top of the normal block model.
(A crafting table with a floating rotating text model on top)

Posted

The TESR above is for the model that I'm planning to be rotating, I just haven't done it yet when I saw that the model wasn't loading. The fixed model is just the block of the tileentity. Also, could you explain what a FastTESR is please?

Posted (edited)

Ok, thanks for the answer! I would like to directly  get the model and bake it if possible, but for me the ModelLoader.getModel method doesn't exist. Has it been replaced in 1.11.2?
 

Edited by grand_gibus

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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