Jump to content

Recommended Posts

Posted

Hello, i am currently developing mod, which bring clans into the game and i need  pass the clan's icon from server to client. This icon have a light weight (it's 16x16) and i think it will be good to keep them all in ./icons folder of the Minecraft directory. But i don't know to convert File to ResourceLocation to render it in the game. Can somebody help me with this?

Posted

1. Pack all .png to 256x256 sheet.

2. Put that sheet somewhere in server files.

3. Create SpecialResourcePack extends AbstractResourcePack (or FileResourcePack).

4. Use packets (send .png as stream): either SimpleNetworkWrapper or setup your own sending (open new thread)

5. On receiver (client) side you will now have some .png - use SpecialResourcePack to load image as resource (inputStream).

6. Use:

mc.getTextureManager().bindTexture(textureSheet);
this.drawTexturedModalRect(x, y, u, v, 16, 16);

To draw image.

 

Note: Instead of writing whole new implementation of ResourcePack you can use FileResourcePack.

1. After finishing downloading .png, place it into .zip or .jar (on client side).

2. Load .jar/.zip as FileResourcePack.

3. That way you will also inherit file structure (e.g: assets/something/lol/textureSheet.png) of that .jar.

 

Example of loading FileResourcePack:

List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao");

defaultResourcePacks.add(new MyFileResourcePack(new File("C:/Users/Me/Something/.minecraft/theJar.jar")));
Minecraft.getMinecraft().refreshResources();

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

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.