Отображения уровня заряда машины

Версия Minecraft
1.7.10
769
1
42
Доброе утро. Делаю собственную машину, почти все сделал, осталось лишь решить одну проблему. В моем гуи есть отображение уровня заряда. Я хочу, чтобы полоска заряда отображалась снизу вверх, а не слево направо. Подскажите, как исправить?
Гуи
Код:
package vacuum.core.gui;

import java.util.ArrayList;
import java.util.List;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import micdoodle8.mods.galacticraft.core.GalacticraftCore;
import micdoodle8.mods.galacticraft.core.client.gui.container.GuiContainerGC;
import micdoodle8.mods.galacticraft.core.client.gui.element.GuiElementInfoRegion;
import micdoodle8.mods.galacticraft.core.energy.EnergyDisplayHelper;
import micdoodle8.mods.galacticraft.core.util.EnumColor;
import micdoodle8.mods.galacticraft.core.util.GCCoreUtil;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import vacuum.core.inventory.CoreMaceratorContainer;
import vacuum.core.tile.CoreTileEntityMacerator;

@SideOnly(Side.CLIENT)
public class CoreMaceratorGui extends GuiContainerGC {
 
    private static final ResourceLocation maceratorTexture = new ResourceLocation("horizon:textures/gui/gui_Macerator.png");
    private GuiElementInfoRegion electricInfoRegion = new GuiElementInfoRegion(0, 0, 9, 56, null, 0, 0, this);

    private CoreTileEntityMacerator tileEntity;

    public CoreMaceratorGui(InventoryPlayer par1InventoryPlayer, CoreTileEntityMacerator tileEntity) {
        super(new CoreMaceratorContainer(par1InventoryPlayer, tileEntity));
        this.tileEntity = tileEntity;
    }

    @Override
    public void initGui() {
        super.initGui();
        this.electricInfoRegion.tooltipStrings = new ArrayList<String>();
        this.electricInfoRegion.xPosition = (this.width - this.xSize) / 2 + 158;
        this.electricInfoRegion.yPosition = (this.height - this.ySize) / 2 + 8;
        this.electricInfoRegion.parentWidth = this.width;
        this.electricInfoRegion.parentHeight = this.height;
        this.infoRegions.add(this.electricInfoRegion);
        List<String> batterySlotDesc = new ArrayList<String>();
        batterySlotDesc.add(GCCoreUtil.translate("gui.batterySlot.machineDesc.0"));
        batterySlotDesc.add(GCCoreUtil.translate("gui.batterySlot.machineDesc.1"));
        this.infoRegions.add(new GuiElementInfoRegion((this.width - this.xSize) / 2 + 72, (this.height - this.ySize) / 3 + 62, 18, 18, batterySlotDesc, this.width, this.height, this));
    }

    @Override
    protected void drawGuiContainerForegroundLayer(int par1, int par2) {
        this.fontRendererObj.drawString(this.tileEntity.getInventoryName(), 45, 6, 4210752);
        String displayText = "";

        if (this.tileEntity.processTicks > 0) {
            displayText = EnumColor.BRIGHT_GREEN + GCCoreUtil.translate("gui.status.running.maceratorName");
        } else {
            displayText = EnumColor.ORANGE + GCCoreUtil.translate("gui.status.idle.maceratorName");
        }

        this.fontRendererObj.drawString(GCCoreUtil.translate("gui.message.status.maceratorName") + ": " + displayText, 97, 52, 4210752);
        this.fontRendererObj.drawString(GCCoreUtil.translate("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
        this.mc.renderEngine.bindTexture(CoreMaceratorGui.maceratorTexture);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        int containerWidth = (this.width - this.xSize) / 2;
        int containerHeight = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
        int scale;

        List<String> electricityDesc = new ArrayList<String>();
        electricityDesc.add(GCCoreUtil.translate("gui.energyStorage.desc.0"));
        EnergyDisplayHelper.getEnergyDisplayTooltip(this.tileEntity.getEnergyStoredGC(), this.tileEntity.getMaxEnergyStoredGC(), electricityDesc);
        this.electricInfoRegion.tooltipStrings = electricityDesc;

        if (this.tileEntity.processTicks > 0) {
            scale = (int) ((double) this.tileEntity.processTicks / (double) this.tileEntity.processTime * 23);
            this.drawTexturedModalRect(containerWidth + 66, containerHeight + 14, 176, 70, 30 - scale, 41);
        }

        if (this.tileEntity.getEnergyStoredGC() > 0) {
            scale = this.tileEntity.getScaledElecticalLevel(8);
            this.drawTexturedModalRect(containerWidth + 159, containerHeight + 8, 176, 7, scale, 54);
            this.drawTexturedModalRect(containerWidth + 157, containerHeight + 66, 176, 61, 11, 10);
        }
    }
}
 
769
1
42
timaxa007 написал(а):
Код:
GL11.glPushMatrix();
GL11.glTranslatef(150F, 250F, 0F);//Может быть другим
GL11.glRotatef(-90F, 0F, 0F, 1F);
//текст
GL11.glPopMatrix();
Извиняюсь за свою тупость. Куда его лучше всего пихнуть?
Попробовал сюда, но полоска исчезла вообще
Код:
if (this.tileEntity.getEnergyStoredGC() > 0) {
         scale = this.tileEntity.getScaledElecticalLevel(8);//размер по ширине
         GL11.glPushMatrix();
            GL11.glTranslatef(150F, 250F, 0F);
            GL11.glRotatef(-90F, 0F, 0F, 1F);
            this.drawTexturedModalRect(containerWidth + 159, containerHeight + 8, 176, 7, scale, 54);//параметры полоски
            GL11.glPopMatrix();
            this.drawTexturedModalRect(containerWidth + 157, containerHeight + 66, 176, 61, 11, 10);//параметры иконки энергии
        }
 

timaxa007

Модератор
5,831
409
672
Тфу... Думал тебе текст. Но можно так-же поворачивая на 90 градусов, либо scale ставить в другие аргументы метода drawTexturedModalRect.
На счёт первого, могу посоветовать запускать через жука поворачивать на определённое количество градусов и glTranslatef из менять его положение, чтобы он оставался на экране и/или в нужной позиции.
На счёт второго, пробуй. Я точно не знаю какие параметры. Но примерно
Код:
drawTexturedModalRect(containerWidth + 159, containerHeight + 8 - scl1 + 8, 176 - scl1 + 8, 7, 8, 54 + scl1 - 8);
Но я не знаю какие именно размеры у тебя.
 
5,018
47
783
RonyC написал(а):
Почти сработало. Только сначала резко появляется одна часть полоски, а затем она достраивается постепенно.

Вопрос не по теме. Я тебя раскусил ! -Ты делаешь аддон для Galactic крафта. Что за аддон?
 
769
1
42
Maxik001 написал(а):
RonyC написал(а):
Почти сработало. Только сначала резко появляется одна часть полоски, а затем она достраивается постепенно.

Вопрос не по теме. Я тебя раскусил ! -Ты делаешь аддон для Galactic крафта. Что за аддон?
Ну как бээ... Да, даже не скрывал. Vacuum Horizon


Тимахе и Дахаке спасибо. Но проблема еще есть. Переписал код вот так
Код:
if (this.tileEntity.getEnergyStoredGC() > 0) {
         scale = this.tileEntity.getScaledElecticalLevel(7);
         this.drawTexturedModalRect(containerWidth + 159, containerHeight + 2 + 12 - scale, 176, 13 - scale, 7, scale + 48);//полоска заряда
        }

Но, как я уже сказал, она отображается не постепенно. Сначала появляется ее большая часть, а затем постепенно заполняется остальная. Подскажите, что сделать, чтобы она вся постепенно заполнялась?
 
Сверху