Jump to content

[1.8.9] Generating Block Texture On Runtime


AManNeedaAName

Recommended Posts

The textures are randomly generated (choose one):

- On MC load.

- On world load.

- A few times while world running.

- 9000+ times / tick (╯°□°)╯︵ ┻━┻

 

This choice will completely change the way it should be implemented.

Link to comment
Share on other sites

Use a TextureAtlasSprite and override it's

load

method and make sure that it gets added to the sprite sheet (subscribe to TextureStitchEvent).

 

Do note that by overriding

load

you'll end up skipping LOTS of vanilla debug behavior regarding missing/corrupt textures and the game will either crash (in vanilla code), or not behave properly, and you'll be on your own to debug.

 

Here's a TextureAtlasSprite class I wrote once that combines two different .png files during startup.

 

https://github.com/Draco18s/HarderStuff/blob/master/src/main/java/com/draco18s/hardlib/client/TextureAtlasDynamic.java

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

@Draco18s woooow... Stop it... Why so much pain? Srsly?

 

Step 1: create a texture location, for example "cookiemod:zenyancookie" and use it in your block json.

Step 2: Create custom

IResourcePack

implementation, throw it into default resource packs in minecraft using reflection.

Step 3: once somebody asks for texture resource and it's your texture (check domain and location, location will be textures/senyancookie in this case), return resource that ImageIOs your png into output stream, which you clone into inout stream using apache stream utils and return.

Step 3.5: If you want your image to persist between RP reloads, just output it into

ByteArrayOutputStream

, store

byte[]

and return

ByteArrayInputStream

from that array as resource.

Link to comment
Share on other sites

@Draco18s woooow... Stop it... Why so much pain? Srsly?

 

Gosh, probably because that's what people told me to do on this forum back when I was trying to figure out how to combine textures....

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Is not so easy to make random block texture as before. From what I read you can simply generate one and apply it directly to a Block by using the methods before 1.8 which are still buried in the code but you need to create a fake json model with everything empty and you cannot add it to a creative tab. Is a hack but is not guaranteed is gonna work forever.

 

in the json model you would have something like

{

    "": {

        "": { "": "" }

    }

}

 

or some other bs system. I forget now. But there is a hacky way to do it. It only works for blocks.

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

@trollworkout Did you read my previous post? It's totally possible and not hard at all.

 

@Draco18s This is applicable in 1.8, hell that resource pack method works in 1.7.10 (but not needed).

Since 1.9, we've got another way of doing this, with

IBaked

, in case we have to combine tons of layers (to not hurt performance).

Just FMI (for my information), how are/were you actually using that dynamic atlas sprite?

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