Jump to content

[1.7.10] URL to ResourceLocation


Emax

Recommended Posts

Hi, it's possible to transform a url (wich locate an image png) to a resource location?

i know how to download the image but i can't transform it to a resource location

Nope it is not... And what you're doing is (can be better) done in completely other way...

Link to comment
Share on other sites

elix, what? You are wrong (about 1st thing) :D

 

It is possible. I am assuming you are asking about loading .png file from anywhere. In that case you can implement IResourcePack that allows you to generate virtual resources with getInputStream. Once you generate resources you can put them into Minecraft#defaultResourcePacks using reflection (ReflectionObfuscationHelper).

 

Note: getInputStream allows any input, you can probably use direct stream from Http, just make sure to use multi-threading when you are downloading files.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

elix, what? You are wrong (about 1st thing) :D

 

It is possible. I am assuming you are asking about loading .png file from anywhere. In that case you can implement IResourcePack that allows you to generate virtual resources with getInputStream. Once you generate resources you can put them into Minecraft#defaultResourcePacks using reflection (ReflectionObfuscationHelper).

 

Note: getInputStream allows any input, you can probably use direct stream from Http, just make sure to use multi-threading when you are downloading files.

He wanted to transform Image to ResourceLocation, which is not possible. ResourceLocation is just reference, "path", to resource with modid and internal path. What he needed to use, you said above...

Link to comment
Share on other sites

elix, what? You are wrong (about 1st thing) :D

 

It is possible. I am assuming you are asking about loading .png file from anywhere. In that case you can implement IResourcePack that allows you to generate virtual resources with getInputStream. Once you generate resources you can put them into Minecraft#defaultResourcePacks using reflection (ReflectionObfuscationHelper).

 

Note: getInputStream allows any input, you can probably use direct stream from Http, just make sure to use multi-threading when you are downloading files.

He wanted to transform Image to ResourceLocation, which is not possible. ResourceLocation is just reference, "path", to resource with modid and internal path. What he needed to use, you said above...

No. It is actually possible. Think about skin, it is also from URL!

So, Look into the class 'DynamicTexture'. It will give you a hint.

+ This thread will also help you: http://www.minecraftforge.net/forum/index.php/topic,25161.msg127886.html#msg127886

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

elix, what? You are wrong (about 1st thing) :D

 

It is possible. I am assuming you are asking about loading .png file from anywhere. In that case you can implement IResourcePack that allows you to generate virtual resources with getInputStream. Once you generate resources you can put them into Minecraft#defaultResourcePacks using reflection (ReflectionObfuscationHelper).

 

Note: getInputStream allows any input, you can probably use direct stream from Http, just make sure to use multi-threading when you are downloading files.

He wanted to transform Image to ResourceLocation, which is not possible. ResourceLocation is just reference, "path", to resource with modid and internal path. What he needed to use, you said above...

No. It is actually possible. Think about skin, it is also from URL!

So, Look into the class 'DynamicTexture'. It will give you a hint.

+ This thread will also help you: http://www.minecraftforge.net/forum/index.php/topic,25161.msg127886.html#msg127886

ResourceLocation and Dynamic texture or New resource pack are different things. Resource location is just 2 strings showing mc resource path... But in order to display that texture, you need or DynaimcTexture or dynamic resource pack... Again, ResourceLocation is just a location, path and not texture it self...

Link to comment
Share on other sites

ResourceLocation and Dynamic texture or New resource pack are different things. Resource location is just 2 strings showing mc resource path... But in order to display that texture, you need or DynaimcTexture or dynamic resource pack... Again, ResourceLocation is just a location, path and not texture it self...

Yes, you're right. I might see illusion or something... (I saw something setting ResourceLocation in DynamicTexture code)

Anyway, Dynamic Texture will be needed to do what OP wanted to do.

 

EDIT: I'd upse my previous admission, see TextureManager#getDynamicTextureLocation code.

It registers the DynamicTexture with key 'ResourceLocation'.

So in this case ResourceLocation is actually an abstract expression of resource location, as key for the resource

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.