好吧,我想在热工具栏中更改minecraft的图标。我已经知道我必须编辑源代码,并且已经找到了设置图标的行(见下文)。我必须做一个inputstream,但是我不知道我必须把图标放在什么路径中,以及原始图标是什么路径。
我已经试着做一个新的资产文件夹,把png文件放在那里,或者直接放进minecraft文件夹。
提前谢谢亚伦
调用setwindowicon()方法:
//Original Code InputStreams
//InputStream inputstream = this.getPackFinder().getVanillaPack().getResourceStream(ResourcePackType.CLIENT_RESOURCES, new ResourceLocation("icons/icon_16x16.png"));
//InputStream inputstream1 = this.getPackFinder().getVanillaPack().getResourceStream(ResourcePackType.CLIENT_RESOURCES, new ResourceLocation("icons/icon_32x32.png"));
//My attempt on InputStreams
InputStream inputstream = new FileInputStream("icons/icon_16x16.png");
InputStream inputstream1 = new FileInputStream("icons/icon_32x32.png");
this.mainWindow.setWindowIcon(inputstream, inputstream1);
setwindowicon()方法:
public void setWindowIcon(InputStream p_216529_1_, InputStream p_216529_2_) {
RenderSystem.assertThread(RenderSystem::isInInitPhase);
try (MemoryStack memorystack = MemoryStack.stackPush()) {
if (p_216529_1_ == null) {
throw new FileNotFoundException("icons/icon_16x16.png");
}
if (p_216529_2_ == null) {
throw new FileNotFoundException("icons/icon_32x32.png");
}
IntBuffer intbuffer = memorystack.mallocInt(1);
IntBuffer intbuffer1 = memorystack.mallocInt(1);
IntBuffer intbuffer2 = memorystack.mallocInt(1);
Buffer buffer = GLFWImage.mallocStack(2, memorystack);
ByteBuffer bytebuffer = this.loadIcon(p_216529_1_, intbuffer, intbuffer1, intbuffer2);
if (bytebuffer == null) {
throw new IllegalStateException("Could not load icon: " + STBImage.stbi_failure_reason());
}
buffer.position(0);
buffer.width(intbuffer.get(0));
buffer.height(intbuffer1.get(0));
buffer.pixels(bytebuffer);
ByteBuffer bytebuffer1 = this.loadIcon(p_216529_2_, intbuffer, intbuffer1, intbuffer2);
if (bytebuffer1 == null) {
throw new IllegalStateException("Could not load icon: " + STBImage.stbi_failure_reason());
}
buffer.position(1);
buffer.width(intbuffer.get(0));
buffer.height(intbuffer1.get(0));
buffer.pixels(bytebuffer1);
buffer.position(0);
GLFW.glfwSetWindowIcon(this.handle, buffer);
STBImage.stbi_image_free(bytebuffer);
STBImage.stbi_image_free(bytebuffer1);
} catch (IOException ioexception) {
LOGGER.error("Couldn't set icon", (Throwable)ioexception);
}
}
暂无答案!
目前还没有任何答案,快来回答吧!