65 lines
2.4 KiB
Java
65 lines
2.4 KiB
Java
package net.minecraft.client.gui.screens.inventory;
|
|
|
|
import java.util.List;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.gui.GuiGraphics;
|
|
import net.minecraft.client.gui.navigation.ScreenPosition;
|
|
import net.minecraft.client.gui.screens.recipebook.FurnaceRecipeBookComponent;
|
|
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
|
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.AbstractFurnaceMenu;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public abstract class AbstractFurnaceScreen<T extends AbstractFurnaceMenu> extends AbstractRecipeBookScreen<T> {
|
|
private final ResourceLocation texture;
|
|
private final ResourceLocation litProgressSprite;
|
|
private final ResourceLocation burnProgressSprite;
|
|
|
|
public AbstractFurnaceScreen(
|
|
T menu,
|
|
Inventory playerInventory,
|
|
Component title,
|
|
Component recipeFilterName,
|
|
ResourceLocation texture,
|
|
ResourceLocation litProgressSprite,
|
|
ResourceLocation burnProgressSprite,
|
|
List<RecipeBookComponent.TabInfo> tabInfos
|
|
) {
|
|
super(menu, new FurnaceRecipeBookComponent(menu, recipeFilterName, tabInfos), playerInventory, title);
|
|
this.texture = texture;
|
|
this.litProgressSprite = litProgressSprite;
|
|
this.burnProgressSprite = burnProgressSprite;
|
|
}
|
|
|
|
@Override
|
|
public void init() {
|
|
super.init();
|
|
this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2;
|
|
}
|
|
|
|
@Override
|
|
protected ScreenPosition getRecipeBookButtonPosition() {
|
|
return new ScreenPosition(this.leftPos + 20, this.height / 2 - 49);
|
|
}
|
|
|
|
@Override
|
|
protected void renderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) {
|
|
int i = this.leftPos;
|
|
int j = this.topPos;
|
|
guiGraphics.blit(RenderType::guiTextured, this.texture, i, j, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256);
|
|
if (this.menu.isLit()) {
|
|
int k = 14;
|
|
int l = Mth.ceil(this.menu.getLitProgress() * 13.0F) + 1;
|
|
guiGraphics.blitSprite(RenderType::guiTextured, this.litProgressSprite, 14, 14, 0, 14 - l, i + 56, j + 36 + 14 - l, 14, l);
|
|
}
|
|
|
|
int k = 24;
|
|
int l = Mth.ceil(this.menu.getBurnProgress() * 24.0F);
|
|
guiGraphics.blitSprite(RenderType::guiTextured, this.burnProgressSprite, 24, 16, 0, 0, i + 79, j + 34, l, 16);
|
|
}
|
|
}
|