Elborshooter Posted January 21 Report Posted January 21 Game version : 1.21.6 Alright, first of all, I'm a bad programmer that don't know a lot of C#, so most of what I've done so far has been vibe coded with chatgpt (with all the pain that comes from it, like how it kept telling me that what I wanted to do was possible in the newer 1.22+ versions, but not in the old 1.21.6...), don't really like doing that but my adhd would have killed me... With that out of the way, I've been making a mod that allows making clay tablets on which you can write cuneiform strokes however you please. All the logic is pretty much done with the content of the tablet being saved in a TreeAttributes as bytes containing the x,y position (relative to the tablet interface), the length, the angle and the type of stroke. That part is working fine so my question now is whether it could be possible to render those strokes as a texture overlay directly onto the tablet item itself, so that it would be visible even outside of the GUI. I thought about adding alternate temporary textures that could be written over, but that would mean a very limited amount of different tablets at a time, and instead I find a way to generate a new texture for every new tablet, that would mean potential infinite bloat. So instead I'm wondering if it's possible to sort of hack into the rendering method of the textures to add an overlay that would take the same parameters as my treeAttributes, in which case the rendering logic I have for the GUI should be easily re-used (I think...) So that's the question, I hope I'm not being too vague or, more likely, too ambitious...
Elborshooter Posted January 24 Author Report Posted January 24 Alright, I figured it out for the most part by using the OnBeforeRender method. I do have an annoying issue though. The overlay with the strokes renders nicely and is visible both while in my hand or on the ground, but it disappears if there's an item (not a block) in my offhand, or my main hand when the tablet is on the ground, that does not have the Attribute containing the strokes, that includes another tablet that has never been edited, but as soon as it gets edited the overlay works. With another edited tablet With a never edited tablet Any help would be greatly appreciated
Lazouskie Posted January 28 Report Posted January 28 Could it possibly be a client-server sync issue? I believe in a similar sort of way, if you spawn an entity on the client side, it disappears quickly as the server side didn't know about it. Not sure if that would be the case here though, just a thought.
Elborshooter Posted January 29 Author Report Posted January 29 On 1/28/2026 at 1:52 AM, Lazouskie said: Could it possibly be a client-server sync issue? I believe in a similar sort of way, if you spawn an entity on the client side, it disappears quickly as the server side didn't know about it. Not sure if that would be the case here though, just a thought. It shouldn't, the tablets are synced with the server whenever they're modified. My best guess so far is that it's an engine limitation, the OnBeforeRender only runs for one instance of an itemclass at a time or something like that
ThePerfectLink Posted February 8 Report Posted February 8 (edited) Could you elaborate on what you did in order to add an overlay to an item in-hand? I'm currently trying to do something similar in order to bypass an inordinate amount of variants. I've added items to the item overlay via code, but was unable to actually get them to render. Any thoughts as to why that's occurring? Edited February 8 by ThePerfectLink
The Insanity God Posted March 5 Report Posted March 5 On 1/29/2026 at 6:43 PM, Elborshooter said: My best guess so far is that it's an engine limitation, the OnBeforeRender only runs for one instance of an itemclass at a time or something like that I can't say much about what you did wrong but this is not an engine limitation. `OnBeforeRender` runs for every ItemStack (not to be confused with ItemClass, which contains the shared data). I for instance use this method for rendering Ice Cubes in BrainFreeze (there is only 1 ItemClass instance, but each ItemStack renders differently depending on the liquid stored in the ItemStack attributes). On 2/8/2026 at 2:47 AM, ThePerfectLink said: Could you elaborate on what you did in order to add an overlay to an item in-hand? I'm currently trying to do something similar in order to bypass an inordinate amount of variants. I've added items to the item overlay via code, but was unable to actually get them to render. Any thoughts as to why that's occurring? If those variants are fixed (as in you have to chose from a list such as wood types) and not dynamic like with this post then I would recommend looking into Attribute Rendering
Recommended Posts