| 1 | package net.minecraft.client.gui.screens.inventory;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.gui.GuiGraphicsExtractor;
|
| 6 | import net.minecraft.client.renderer.RenderPipelines;
|
| 7 | import net.minecraft.network.chat.Component;
|
| 8 | import net.minecraft.resources.Identifier;
|
| 9 | import net.minecraft.util.Mth;
|
| 10 | import net.minecraft.world.entity.player.Inventory;
|
| 11 | import net.minecraft.world.inventory.BrewingStandMenu;
|
| 12 |
|
| 13 | @Environment(EnvType.CLIENT)
|
| 14 | public class BrewingStandScreen extends AbstractContainerScreen<BrewingStandMenu> {
|
| 15 | private static final Identifier FUEL_LENGTH_SPRITE = Identifier.withDefaultNamespace("container/brewing_stand/fuel_length");
|
| 16 | private static final Identifier BREW_PROGRESS_SPRITE = Identifier.withDefaultNamespace("container/brewing_stand/brew_progress");
|
| 17 | private static final Identifier BUBBLES_SPRITE = Identifier.withDefaultNamespace("container/brewing_stand/bubbles");
|
| 18 | private static final Identifier BREWING_STAND_LOCATION = Identifier.withDefaultNamespace("textures/gui/container/brewing_stand.png");
|
| 19 | private static final int[] BUBBLELENGTHS = new int[]{29, 24, 20, 16, 11, 6, 0};
|
| 20 |
|
| 21 | public BrewingStandScreen(final BrewingStandMenu menu, final Inventory inventory, final Component title) {
|
| 22 | super(menu, inventory, title);
|
| 23 | }
|
| 24 |
|
| 25 | @Override
|
| 26 | protected void init() {
|
| 27 | super.init();
|
| 28 | this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2;
|
| 29 | }
|
| 30 |
|
| 31 | @Override
|
| 32 | public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
|
| 33 | super.extractBackground(graphics, mouseX, mouseY, a);
|
| 34 | int xo = (this.width - this.imageWidth) / 2;
|
| 35 | int yo = (this.height - this.imageHeight) / 2;
|
| 36 | graphics.blit(RenderPipelines.GUI_TEXTURED, BREWING_STAND_LOCATION, xo, yo, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256);
|
| 37 | int fuel = this.menu.getFuel();
|
| 38 | int totalFuel = this.menu.getTotalFuel();
|
| 39 | int fuelLength = totalFuel > 0 ? Mth.clamp(Mth.positiveCeilDiv(18 * fuel, totalFuel), 0, 18) : 0;
|
| 40 | if (fuelLength > 0) {
|
| 41 | graphics.blitSprite(RenderPipelines.GUI_TEXTURED, FUEL_LENGTH_SPRITE, 18, 4, 0, 0, xo + 60, yo + 44, fuelLength, 4);
|
| 42 | }
|
| 43 |
|
| 44 | int tickCount = this.menu.getBrewingTicks();
|
| 45 | int totalTickCount = this.menu.getTotalBrewingTicks();
|
| 46 | if (tickCount > 0 && totalTickCount > 0) {
|
| 47 | int length = (int)(28.0F * (1.0F - (float)tickCount / totalTickCount));
|
| 48 | if (length > 0) {
|
| 49 | graphics.blitSprite(RenderPipelines.GUI_TEXTURED, BREW_PROGRESS_SPRITE, 9, 28, 0, 0, xo + 97, yo + 16, 9, length);
|
| 50 | }
|
| 51 |
|
| 52 | length = BUBBLELENGTHS[tickCount / 2 % 7];
|
| 53 | if (length > 0) {
|
| 54 | graphics.blitSprite(RenderPipelines.GUI_TEXTURED, BUBBLES_SPRITE, 12, 29, 0, 29 - length, xo + 63, yo + 14 + 29 - length, 12, length);
|
| 55 | }
|
| 56 | }
|
| 57 | }
|
| 58 | }
|
| 59 |
|