SethGunnells Posted February 27, 2013 Posted February 27, 2013 Hey guys. I'm relatively new to this whole modding scene, but I've got a pretty solid Java background. Here's the skinny: I'm trying to create a block with a custom shape and appearance. I've created a model and texture and it seems to be correct. What I'm now trying to figure out is how to tell Minecraft to use my model when rendering my block. My searches have turned up little information on this subject and what information I've found is either outdated or doesn't seem to agree with anything else I've read. I think it would be helpful if I understood the flow of information in terms of how Minecraft renders blocks, but I can't even begin to attempt to trace through Minecraft's rendering code. The bottom line is this: how do I use a custom model for a block? Thanks for any help. Quote
mnn Posted February 27, 2013 Posted February 27, 2013 you can check out these source files (it's a simple decorative block): https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/block/BlockColumn.java https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/client/TileEntityColumnRenderer.java https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/client/ClientProxy.java#L39 https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/client/ModelColumn.java the model class comes from Techne with just few modifications (if I remember correctly setRotationAngles and render methods). ^source code is working, but some things may be redundant or not done the best way (like manual creation of TE by block). Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
SethGunnells Posted February 27, 2013 Author Posted February 27, 2013 Thanks, guys! Very helpful! Quote
robustus Posted March 13, 2013 Posted March 13, 2013 Ive been messing around with custom model block and just had a question. Basically the model is like a fence block where it will render differently if certain conditions are met. Im wondering the best place to put these conditions. I've gotten it to work but Im just paranoid that I put it in the wrong place, because it seems like I may have put the conditions in a place where each block checks the conditions every second, but I want it only to check when the blocks surrounding it change. I placed the conditions in the renderModelAt function within my TileEntityRenderer and it passes those conditions to the model and renders. Obviously though the conditions will only change the model when an adjacent block is changed so I wouldn't need to do these checks when that happens, but I am having a hunch that the check is happening continuously though I could be wrong. Hope I explained that properly. If anyone could give some advice that would be great. Quote
mnn Posted March 13, 2013 Posted March 13, 2013 renderModelAt is called not every second, but every frame (for each your custom block). I'd move the checks into block's onNeighborBlockChange (and fire block changed when renderer type changes). Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
robustus Posted March 13, 2013 Posted March 13, 2013 Not sure how I should go about it, is there a hook to update the model from neighborchange or do i have to have a separate model for each state? Quote
mnn Posted March 13, 2013 Posted March 13, 2013 I'd do this: add a field to fence TE, this field will store which model to render (I mean type like crossing or single rod). this field will be used in renderer instead of the heavy conditions. to the fence block on neighbour change you'd move those conditions and result would be saved in the TE's field. You might need to alert neighbour blocks if your render type changes (it depens on how exactly you have implemented conditions). Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
Recommended Posts
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.