编程我的第一个Minecraft Mod时遇到了问题。
以下是源代码:
Events.java:
public class Events {
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent event) {
if(!event.isCancelable() && event.type == ElementType.EXPERIENCE && !Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) {
int posX = event.resolution.getScaledWidth() / 2 + 10;
int posY = event.resolution.getScaledHeight() - 48;
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("tc:textures/gui/thermo-icon.png"));
Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect(posX + 9, posY + 3, 0, 9, 71, 3);
}
}
}
注意红色椭圆(我用GIMP添加它),里面有一个黑色矩形(我还没有用GIMP添加它)......它太小而且没有纹理......
我遵循了本教程(https://www.youtube.com/watch?v=oi41BAlRjtE),但仍然没有工作......
有任何解决方案吗?
更新 - - - - - -
感谢所有人的帮助,我明白高度= 3像素太小......但现在我还有一个问题......
中心的浅灰色矩形应为a 正方形,黑色部分应为"圆"。
有谁知道错误比例的原因?谢谢!
答案 0 :(得分:1)
太小了?
您期望的尺寸是多少?
drawTexturedModalRect(posX + 9, posY + 3, 0, 9, 71, 3);
它不是71像素长,3高......你提供的是什么?很难说。也许纹理是有效的,但是你将其缩小了9个像素(当你只绘制3个像素时),但看起来你使用的是bindTexture错误。它需要从getTexture返回的int。
int i = mc.renderEngine.getTexture("/Items/GUI/mixer.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
有一个很好的wiki /教程,可以帮助你做一些可能有用的mod:http://www.minecraftforge.net/wiki/Gui_Overlay#Mod_Code