本帖最后由 和煦樱 于 2020-8-6 21:12 编辑


复制代码
正常情况下:

快捷栏里有 1数量 的物品时:

这个渲染问题我的代码要怎么改才好...求解 没学过GL11 抱歉..
- public class Playerhud {
-
- public static class GUIRenderEventClass extends GuiScreen {
-
- Minecraft Mc = Minecraft.getMinecraft();
- private ResourceLocation Hud = new ResourceLocation("textures/MainHud.png");
-
- @SubscribeEvent
- public void playerHealth(RenderGameOverlayEvent.Pre event) {
- int width = (event.resolution.getScaledWidth()-227)/2;
- int height = event.resolution.getScaledHeight();
- if(event.resolution.getScaledWidth()%2 != 0) {
- width = width-1;
- }
- Mc.renderEngine.bindTexture(Hud);
- Mc.ingameGUI.drawTexturedModalRect(width-1, height-40, 0, 0, 227, 40);
- float HealthPer = Mc.thePlayer.getHealth()/Mc.thePlayer.getMaxHealth();
- if(Mc.thePlayer.getActivePotionEffect(Potion.wither) == null) {
- if(Mc.thePlayer.getActivePotionEffect(Potion.poison) == null) {
- Mc.ingameGUI.drawTexturedModalRect(width+23, height-37, 15, 40, (int)Math.ceil(182*(HealthPer)), 8);
- } else {
- Mc.ingameGUI.drawTexturedModalRect(width+23, height-37, 15, 48, (int)Math.ceil(182*(HealthPer)), 8);
- }
- } else {
- Mc.ingameGUI.drawTexturedModalRect(width+23, height-37, 15, 56, (int)Math.ceil(182*(HealthPer)), 8);
- }
- Mc.ingameGUI.drawTexturedModalRect(width+15, height-(22-20+(int)Math.ceil(20*Mc.thePlayer.experience)), 0, 40, 5, (int)Math.ceil(20*Mc.thePlayer.experience));
- if(Mc.thePlayer.getActivePotionEffect(Potion.hunger) == null) {
- Mc.ingameGUI.drawTexturedModalRect(width+208, height-2-Mc.thePlayer.getFoodStats().getFoodLevel(), 5, 40, 5, Mc.thePlayer.getFoodStats().getFoodLevel());
- } else {
- Mc.ingameGUI.drawTexturedModalRect(width+208, height-2-Mc.thePlayer.getFoodStats().getFoodLevel(), 10, 40, 5, Mc.thePlayer.getFoodStats().getFoodLevel());
- }
- if(event.type == ElementType.HEALTH) {
- event.setCanceled(true);
- }
- if(event.type == ElementType.ARMOR) {
- event.setCanceled(true);
- }
- if(event.type == ElementType.EXPERIENCE) {
- event.setCanceled(true);
- }
- if(event.type == ElementType.FOOD) {
- event.setCanceled(true);
- }
- }
-
- }
-
- public void load() {
- MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass());
- }
- public void preInit(FMLPreInitializationEvent event) {}
- public void registerRenderers() {}
-
- }
帮改这段代码 +Q 894351533 报酬你开
- if (e.getType().equals(RenderGameOverlayEvent.ElementType.ALL)) {
- GlStateManager.pushMatrix();
- GlStateManager.enableAlpha();
- GlStateManager.enableBlend();
- // todo
- GlStateManager.popMatrix();
- }
1710没有GlStateManager.. 给灰灰打钱了 sry..