Jump to content

Recommended Posts

Posted

I made a GUI where the player can click a button to reload texture.

What I want is that the button will load a texture called testmodel.png inside .minecrat folder

 

Every time the user change the texture using Paint.NET, put the texture at this folder and click this button, the texture must be loaded and my mob need to refresh the texture to the new edited one.

 

Any ideas to guid me on this?

 

I think it doesn't matter if the texture will be on a single png file or inside resourcepack, what I really need is to load this new edited texture every time player clicks the button, without the need of restarting minecraft. just read and refresh it on-line

 

Thanks

†GnR† Slash

can one man truly make a difference?

Posted

Minecraft already has a feature to reload the game assets. Hit F3+T in a world and it will reload all the game assets, including resource packs.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

If you want to understand resources as whole - look into GuiResourcePacks (naming may be different).

 

In particular Minecraft.getMinecraft().refreshResources();

This allows you to "recreate" resources. They will be reloaded from Minecraft#defaultResourcePacks which to put it in simple words "contains all packs from which resources will be collected and will create all available resources".

 

Now, in your case you will want to either:

 

1. Put your .png into your pack (your mod or texturepack) and reload resources, they will simply reload all .jar and .zip resources.

* Here is a big note: I am talking partially hypothetically so you might have to remove pack from Minecraft#defaultResourcePacks and re-add it for the pack itself to detect "changes" (like you putting a .png file inside). I don't think so, but MAYBE.

 

OR

 

2. Treat your resource as custom implementation of IResourcePack which can read input stream directly from /.minecraft/directory/file.png

In that case - yeah, reloading will pretty much reload it form directory you want.

* Note: Again - like before, you might have to re-add it.

 

Other stuff:

1. I am not sure if this is still a thing in 1.9+ (was earlier), but to access Minecraft#defaultResourcePacks you will need reflection. Read up on Java tuts.

2. Synchronization WILL be a bitch here. Is this supposed to be client-only feature, or should server be able to set such .pngs (server resourcepacks) or maybe you want "admin" which will be able to change stuff for other players? That all can be done with some Java magic, but hell - lots of vanilla-code-reading and even more work with internals and this is like advanced (quite very) level of modding.

 

EDIT

 

Minecraft already has a feature to reload the game assets. Hit F3+T in a world and it will reload all the game assets, including resource packs.

 

5EvxkUz.png

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

Posted

Look, I am creating a Techne like program but inside Minecraft, using Minecraft features.

It is working well but I need to refresh texture of the model that I am creating without reloading all minecraft textures....

 

I am thinking in this possibility:

 

keep a custom.png file inside my mod.

When a user clicks my button, I will read the custom.png file from .minecraft\custom.png and replace the ResourceLocation without changing the custom.png file inside my jar file.

 

I am trying to figure out a more basic method to acomplish this, I really don't want to build a lot of code or refresh an entire resource pack just for one texture.

I will keep searching and trying methods like these:

 

texturemanager.deleteTexture(MODEL_TEXTURE);

Object object = new ThreadDownloadImageData(textureFile, null, MODEL_TEXTURE, new ImageBufferDownload());

texturemanager.loadTexture(MODEL_TEXTURE, (ITextureObject)object);

 

If someone has a new idea, please tell me. I'll appreciate.

 

Thanks

†GnR† Slash

†GnR† Slash

can one man truly make a difference?

Posted

Ok, I got it working!!!

 

This is what I did:

 

I put a file named entitytest.png inside textures/entities/ of my jar

User will put a new texture in this folder .minecraft\

When he clicks the button, I execute this piece of magic code:

 

	String textureName = "entitytest.png";
	File textureFile = null;
	try { textureFile = new File(Minecraft.getMinecraft().mcDataDir.getCanonicalPath(), textureName); } catch (Exception ex) {}

	if (textureFile != null && textureFile.exists()) {
		ResourceLocation MODEL_TEXTURE = Resources.OTHER_TESTMODEL_CUSTOM;

		TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
		texturemanager.deleteTexture(MODEL_TEXTURE);
		Object object = new ThreadDownloadImageData(textureFile, null, MODEL_TEXTURE, new ImageBufferDownload());
		texturemanager.loadTexture(MODEL_TEXTURE, (ITextureObject)object);

		return true;
	} else {
		return false;
	}

 

Where Resources.OTHER_TESTMODEL_CUSTOM

 

is

 

new ResourceLocation(lostworld.lib.References.MODID,"textures/entities/entitytest.png");

 

;) ;) ;) ;) ;)

  • Like 1

†GnR† Slash

can one man truly make a difference?

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.