Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Custom Block Renderer


SethGunnells
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

 

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

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

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.

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

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello There! In the 73rd episode of Bed Wars we get into a lobby with a guy who had a cool name and for some reason Ben is very impressed with the name and thus the title!  
    • I have been trying to install forge, but I can't even get the installer to run. I'm really not sure what the issue is, first let me make sure I am even using the installer right, I downloaded the forge installer matching my minecraft version (1.19.2), if I double click the .jar from the download then I see a flash of a black window that immediately disappears. If I use a command prompt, I receive the following output: C:\Users\austi> java -jar forge-1.19.2-43.0.19-installer.jar Error: Unable to access jarfile forge-1.19.2-43.0.19-installer.jar   I feel like this is more likely a java issue than a forge issue but I was hoping that people here might be able to help. I've tried a couple versions of java, at first I was using 8 I believe because all of the install guides for forge were a bit older so they linked to the java website rather than oracle. I tried version 18 from the oracle site and received the same result from command prompt. It is also entirely possible that I am doing something else wrong that is blatantly obvious to everyone else.
    • Here is my configuration: % java -version java version "18.0.2" 2022-07-19 Java(TM) SE Runtime Environment (build 18.0.2+9-61) Java HotSpot(TM) 64-Bit Server VM (build 18.0.2+9-61, mixed mode, sharing) forge-1.19-41.1.0-mdk on macOS Monterey 12.5 I ran the command: ./gradlew genEclipseRuns and was hoping it will generate the Eclipse project files for me. The run log is at https://gist.github.com/arun-gupta/06b983a6976b4c0a0f510d0dc225ddd3 and the generated directory structure is at https://gist.github.com/arun-gupta/3f5bfc70ec5d3d903b0f97d42840abda. In previous versions (1.12-ish), it used to generate an eclipse directory but 1.19 does not seem to have it. I tried opening the top-level forge directory but Eclipse does not recognize it as a project as well. How do I open this project in Eclipse now?  
    • I didn't put in credentials, I used it only for testing installing forge. But still the problem mentioned above.
    • I am trying to use Forge 1.18.2, I have checked my firewall, redownloaded Forge, deleted the fml.toml file (which keeps reappearing) and looked at countless help pages. I am just trying to download and use forge so that I can play with my friends and it will not download. It tells me there may be an issue with the Java runtime config and that the exit code is one, and I have copied the exit code.   
  • Topics

×
×
  • Create New...

Important Information

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