PrettyPipes/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerGui.java

42 lines
2 KiB
Java
Raw Normal View History

2020-10-13 18:11:40 +02:00
package de.ellpeck.prettypipes.pressurizer;
import de.ellpeck.prettypipes.PrettyPipes;
2023-07-07 19:54:52 +02:00
import net.minecraft.client.gui.GuiGraphics;
2021-12-02 16:55:04 +01:00
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
2021-12-02 12:31:04 +01:00
import net.minecraft.resources.ResourceLocation;
2021-12-02 16:55:04 +01:00
import net.minecraft.world.entity.player.Inventory;
public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer> {
2020-10-13 18:11:40 +02:00
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/pressurizer.png");
2021-12-02 16:55:04 +01:00
public PressurizerGui(PressurizerContainer screenContainer, Inventory inv, Component titleIn) {
2020-10-13 18:11:40 +02:00
super(screenContainer, inv, titleIn);
2021-12-02 16:55:04 +01:00
this.imageWidth = 176;
this.imageHeight = 137;
2020-10-13 18:11:40 +02:00
}
@Override
2023-07-07 19:54:52 +02:00
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
super.render(graphics, mouseX, mouseY, partialTicks);
this.renderTooltip(graphics, mouseX, mouseY);
2021-12-02 16:55:04 +01:00
if (mouseX >= this.leftPos + 26 && mouseY >= this.topPos + 22 && mouseX < this.leftPos + 26 + 124 && mouseY < this.topPos + 22 + 12)
2023-07-07 19:54:52 +02:00
graphics.renderTooltip(this.font, Component.translatable("info." + PrettyPipes.ID + ".energy", this.menu.tile.getEnergy(), this.menu.tile.getMaxEnergy()), mouseX, mouseY);
2020-10-13 18:11:40 +02:00
}
@Override
2023-07-07 19:54:52 +02:00
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
2023-07-07 20:44:52 +02:00
graphics.drawString(this.font, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752, false);
graphics.drawString(this.font, this.title.getString(), 8, 6, 4210752, false);
2020-10-13 18:11:40 +02:00
}
@Override
2023-07-07 19:54:52 +02:00
protected void renderBg(GuiGraphics graphics, float partialTicks, int x, int y) {
graphics.blit(PressurizerGui.TEXTURE, this.leftPos, this.topPos, 0, 0, 176, 137);
2021-12-02 17:46:56 +01:00
var energy = (int) (this.menu.tile.getEnergyPercentage() * 124);
2023-07-07 19:54:52 +02:00
graphics.blit(PressurizerGui.TEXTURE, this.leftPos + 26, this.topPos + 22, 0, 137, energy, 12);
2020-10-13 18:11:40 +02:00
}
2024-02-03 22:01:43 +01:00
2020-10-13 18:11:40 +02:00
}