package net.minecraft.client.gui.screens.inventory; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.BrewingStandMenu; @Environment(EnvType.CLIENT) public class BrewingStandScreen extends AbstractContainerScreen { private static final ResourceLocation FUEL_LENGTH_SPRITE = ResourceLocation.withDefaultNamespace("container/brewing_stand/fuel_length"); private static final ResourceLocation BREW_PROGRESS_SPRITE = ResourceLocation.withDefaultNamespace("container/brewing_stand/brew_progress"); private static final ResourceLocation BUBBLES_SPRITE = ResourceLocation.withDefaultNamespace("container/brewing_stand/bubbles"); private static final ResourceLocation BREWING_STAND_LOCATION = ResourceLocation.withDefaultNamespace("textures/gui/container/brewing_stand.png"); private static final int[] BUBBLELENGTHS = new int[]{29, 24, 20, 16, 11, 6, 0}; public BrewingStandScreen(BrewingStandMenu menu, Inventory playerInventory, Component title) { super(menu, playerInventory, title); } @Override protected void init() { super.init(); this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2; } @Override public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { super.render(guiGraphics, mouseX, mouseY, partialTick); this.renderTooltip(guiGraphics, mouseX, mouseY); } @Override protected void renderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) { int i = (this.width - this.imageWidth) / 2; int j = (this.height - this.imageHeight) / 2; guiGraphics.blit(RenderType::guiTextured, BREWING_STAND_LOCATION, i, j, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256); int k = this.menu.getFuel(); int l = Mth.clamp((18 * k + 20 - 1) / 20, 0, 18); if (l > 0) { guiGraphics.blitSprite(RenderType::guiTextured, FUEL_LENGTH_SPRITE, 18, 4, 0, 0, i + 60, j + 44, l, 4); } int m = this.menu.getBrewingTicks(); if (m > 0) { int n = (int)(28.0F * (1.0F - m / 400.0F)); if (n > 0) { guiGraphics.blitSprite(RenderType::guiTextured, BREW_PROGRESS_SPRITE, 9, 28, 0, 0, i + 97, j + 16, 9, n); } n = BUBBLELENGTHS[m / 2 % 7]; if (n > 0) { guiGraphics.blitSprite(RenderType::guiTextured, BUBBLES_SPRITE, 12, 29, 0, 29 - n, i + 63, j + 14 + 29 - n, 12, n); } } } }