| 1 | package net.minecraft.client.gui.screens.inventory;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import net.fabricmc.api.EnvType;
|
| 5 | import net.fabricmc.api.Environment;
|
| 6 | import net.minecraft.client.gui.GuiGraphicsExtractor;
|
| 7 | import net.minecraft.client.gui.navigation.ScreenPosition;
|
| 8 | import net.minecraft.client.gui.screens.recipebook.FurnaceRecipeBookComponent;
|
| 9 | import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
| 10 | import net.minecraft.client.renderer.RenderPipelines;
|
| 11 | import net.minecraft.network.chat.Component;
|
| 12 | import net.minecraft.resources.Identifier;
|
| 13 | import net.minecraft.util.Mth;
|
| 14 | import net.minecraft.world.entity.player.Inventory;
|
| 15 | import net.minecraft.world.inventory.AbstractFurnaceMenu;
|
| 16 |
|
| 17 | @Environment(EnvType.CLIENT)
|
| 18 | public abstract class AbstractFurnaceScreen<T extends AbstractFurnaceMenu> extends AbstractRecipeBookScreen<T> {
|
| 19 | private final Identifier texture;
|
| 20 | private final Identifier litProgressSprite;
|
| 21 | private final Identifier burnProgressSprite;
|
| 22 |
|
| 23 | public AbstractFurnaceScreen(
|
| 24 | final T menu,
|
| 25 | final Inventory inventory,
|
| 26 | final Component title,
|
| 27 | final Component recipeFilterName,
|
| 28 | final Identifier texture,
|
| 29 | final Identifier litProgressSprite,
|
| 30 | final Identifier burnProgressSprite,
|
| 31 | final List<RecipeBookComponent.TabInfo> tabInfos
|
| 32 | ) {
|
| 33 | super(menu, new FurnaceRecipeBookComponent(menu, recipeFilterName, tabInfos), inventory, title);
|
| 34 | this.texture = texture;
|
| 35 | this.litProgressSprite = litProgressSprite;
|
| 36 | this.burnProgressSprite = burnProgressSprite;
|
| 37 | }
|
| 38 |
|
| 39 | @Override
|
| 40 | public void init() {
|
| 41 | super.init();
|
| 42 | this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2;
|
| 43 | }
|
| 44 |
|
| 45 | @Override
|
| 46 | protected ScreenPosition getRecipeBookButtonPosition() {
|
| 47 | return new ScreenPosition(this.leftPos + 20, this.height / 2 - 49);
|
| 48 | }
|
| 49 |
|
| 50 | @Override
|
| 51 | public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
|
| 52 | super.extractBackground(graphics, mouseX, mouseY, a);
|
| 53 | int xo = this.leftPos;
|
| 54 | int yo = this.topPos;
|
| 55 | graphics.blit(RenderPipelines.GUI_TEXTURED, this.texture, xo, yo, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256);
|
| 56 | if (this.menu.isLit()) {
|
| 57 | int litSpriteHeight = 14;
|
| 58 | int litProgressHeight = Mth.ceil(this.menu.getLitProgress() * 13.0F) + 1;
|
| 59 | graphics.blitSprite(
|
| 60 | RenderPipelines.GUI_TEXTURED, this.litProgressSprite, 14, 14, 0, 14 - litProgressHeight, xo + 56, yo + 36 + 14 - litProgressHeight, 14, litProgressHeight
|
| 61 | );
|
| 62 | }
|
| 63 |
|
| 64 | int burnSpriteWidth = 24;
|
| 65 | int burnProgressWidth = Mth.ceil(this.menu.getBurnProgress() * 24.0F);
|
| 66 | graphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.burnProgressSprite, 24, 16, 0, 0, xo + 79, yo + 34, burnProgressWidth, 16);
|
| 67 | }
|
| 68 | }
|
| 69 |
|