Jump to content

Question About Binding Textures to Techne Models


Recommended Posts

Hi there guys, I got a (hopefully) simple question here.


I want to make a custom techne model that has both solid components as well as transparent components (basically a fluid tank component on my block). I would like for at run time to change the texture displayed in the transparent shape to represent whatever fluid is currently in block.


Is there a way to do this without redrawing the entire model? Can I bind a texture to just one shape at a time?


Any suggestions?




Link to comment
Share on other sites

First of all, I'd suggest using the Tessellator to render, because it provides more customisability, but that is up to you. Second, you can from the get-go bind two textures and then, in your render code, just don't use the texture. You can then make a boolean that will be true if the tank is active and if the boolean is true, draw render code that uses that texture. If you are using Techne, I can't really help you, so I'd suggest using the Tessellator.

I am the self-nominated Lord of the Mastodons and don't you dare deny it. ;) Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/

Link to comment
Share on other sites

It doesn't matter whether you use Techne or not. If you have custom renderer you can decide what you render and how you render it.

This is how I would do it: Render it in two parts, first the solid (empty) tank and if there it's not empty (you check that from your tileentity in your renderer's renderTileEntityAt(...) method) then you render fluid and bind fluid specific texture. You can decide do you want to use tessellator for that or not.


LoardMastodonFTW: What do you mean by suggesting using the Tessellator?

Link to comment
Share on other sites

Okay, so I did combine the approaches to achieve the effect I wanted.


Essentially my block (a steam boiler) has a techne model that constitutes of frame and transparent glass panels that I render, then within the same render loop I instantiate a tesselator instance and draw a proportional representation of the fluid inside (steam) inside the hollow space of the block.


I guess the only question I have remaining is - The tesselator is painful to work with when designing any model other than crude shapes. Is there a better way to do this? A helper library or a modelling tool that will give you the vertices you need to create the model?


Obviously, for simple cuboids this isn't much of a problem, but if I have to do more complex rendering this way I think I'd rather chop off my own nuts.


Link to comment
Share on other sites

Like I said, you don't have to use tessellator if you don't want to. You just render your model in two parts; you have in your model.java file method named render(...) right? There are names you have given in techne for each parts. Create new method, for example, renderTankContent() and move things you want to render depending on tileentity data to there. Then you just check in your tileentity special renderer you first call yourmodel#render(...) and then check if it should render it with content or not, if so, bind texture for content and render content.


Here is the whole idea how to do this:


tileentity special renderer#renderTileEntityAt(...)


--rotate and scale model as needed--

--bind texture--



--check if tileentity#hasFluid, and if so: --

--bind texture--



Link to comment
Share on other sites

I'm fairly certain for my particular use I would need to use the tesselator because I am drawing a cube and texturing it with my liquid that is of a size on the Y plane that is relative to how much liquid is in the tank.


So, if the tank is 12x12x12 cube at full, it will be 12x6x12 when half full.


Obviously if it was just a matter of swapping out a texture on a cube that was always the same size, then this wouldn't be an issue :D



Link to comment
Share on other sites

argh... If you don't want to try what I just said then ok.. But this is something I just did without using tessellator and with method I explained:


This thing can be turned off (then there is no rotating blue cubes and light indicator on the front turns from green to red)


Link to comment
Share on other sites

Don't get frustrated, you didn't explain yourself very well.


It wasn't until I took a look again at the code Techne generates that I realized I could just instantiate a new ModelRenderer class and .addBox a cube representing my tank of the appropriate dimensions at runtime and go from there.


Don't get me wrong, I am thankful for your help (and it did help give me the right idea). Frankly, I feel stupid for not realizing this earlier, but oh well :D



Link to comment
Share on other sites

Sorry for that =D I just woke up and having flu so it is hard to stay calm =D

Ok but you got the idea? Check the YourModel#render(..) and how it renders those boxes so you understand how you can render things in multiple parts and even rotate and scale those parts as needed without having them affecting other already rendered parts.

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.

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ. Dumping it directly into the thread often triggers the anti-spam and makes it hard to read due to word wrapping
    • Hi all, I'm running a 1.20.1 Minecraft Forge server with a hosting website and something seems to have gone wrong. It started as an occasional crash that has now become extremely frequent and I don't know what exactly is causing it. I already tried disabling watchdog but the server crashes anyway. Oddly it only occasionally generates a crash report after a crash occurs. Based on viewing the server console's research usage it seems that the CPU spikes astronomically high (100% usage), especially when chunks are being loaded or when a new person joins the server. I downloaded Spark to create a profile (https://spark.lucko.me/bBlWe7ou29) but I lack experience with this mod and don't understand what I'm looking at/how this should help me diagnose the issue. I am using a lot of mods so I'm guessing there is some sort of issue there or a corrupted chunk (although MCRF found no chunk errors). We actually don't experience any lag until the crash occurs, so it's some sort of sudden spike in resource usage. Based on the crash report I've already tried removing Canary and Modernfix but there was no change. Thanks for any help you can provide. Specs:  4 cores x 4200MHz AMD Ryzen 9 5950X 4GB RAM Crash report:  
    • will test that once i get home, thanks
    • I am getting this exception (I am new and just trying to create an item) Caused by: java.io.FileNotFoundException: abrasmagics:models/item/ingot_test.json at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]   However the directory is set up correctly and the file does exist   idk how to upload images so here is a treeview of the directories:   src ├───main │ ├───java │ │ └───net │ │ └───abrasmods │ │ └───abrasmagics │ │ ├───init │ │ ├───items │ │ └───utils │ │ ├───handlers │ │ ├───misc │ │ └───proxy │ └───resources │ └───assets │ └───abrasmagics │ ├───models │ │ ├───block │ │ └───item │ └───textures └───test ├───java └───resources   the file ingot_test.json is under models/item. The directory seems fine and the file does exist so anyone plz help.   i am using intellij and is coding for 1.12.2
  • Topics

  • Create New...

Important Information

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