| 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.world.entity.LivingEntity;
|
| 10 | import net.minecraft.world.entity.player.Inventory;
|
| 11 | import net.minecraft.world.inventory.AbstractMountInventoryMenu;
|
| 12 | import org.jspecify.annotations.Nullable;
|
| 13 |
|
| 14 | @Environment(EnvType.CLIENT)
|
| 15 | public abstract class AbstractMountInventoryScreen<T extends AbstractMountInventoryMenu> extends AbstractContainerScreen<T> {
|
| 16 | protected final int inventoryColumns;
|
| 17 | protected float xMouse;
|
| 18 | protected float yMouse;
|
| 19 | protected final LivingEntity mount;
|
| 20 |
|
| 21 | public AbstractMountInventoryScreen(final T menu, final Inventory inventory, final Component title, final int inventoryColumns, final LivingEntity mount) {
|
| 22 | super(menu, inventory, title);
|
| 23 | this.inventoryColumns = inventoryColumns;
|
| 24 | this.mount = mount;
|
| 25 | }
|
| 26 |
|
| 27 | @Override
|
| 28 | public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
|
| 29 | super.extractBackground(graphics, mouseX, mouseY, a);
|
| 30 | int xo = (this.width - this.imageWidth) / 2;
|
| 31 | int yo = (this.height - this.imageHeight) / 2;
|
| 32 | graphics.blit(RenderPipelines.GUI_TEXTURED, this.getBackgroundTextureLocation(), xo, yo, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256);
|
| 33 | if (this.inventoryColumns > 0 && this.getChestSlotsSpriteLocation() != null) {
|
| 34 | graphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.getChestSlotsSpriteLocation(), 90, 54, 0, 0, xo + 79, yo + 17, this.inventoryColumns * 18, 54);
|
| 35 | }
|
| 36 |
|
| 37 | if (this.shouldRenderSaddleSlot()) {
|
| 38 | this.extractSlot(graphics, xo + 7, yo + 35 - 18);
|
| 39 | }
|
| 40 |
|
| 41 | if (this.shouldRenderArmorSlot()) {
|
| 42 | this.extractSlot(graphics, xo + 7, yo + 35);
|
| 43 | }
|
| 44 |
|
| 45 | InventoryScreen.extractEntityInInventoryFollowsMouse(graphics, xo + 26, yo + 18, xo + 78, yo + 70, 17, 0.25F, this.xMouse, this.yMouse, this.mount);
|
| 46 | }
|
| 47 |
|
| 48 | protected void extractSlot(final GuiGraphicsExtractor graphics, final int x, final int y) {
|
| 49 | graphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.getSlotSpriteLocation(), x, y, 18, 18);
|
| 50 | }
|
| 51 |
|
| 52 | @Override
|
| 53 | public void extractRenderState(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
|
| 54 | this.xMouse = mouseX;
|
| 55 | this.yMouse = mouseY;
|
| 56 | super.extractRenderState(graphics, mouseX, mouseY, a);
|
| 57 | }
|
| 58 |
|
| 59 | protected abstract Identifier getBackgroundTextureLocation();
|
| 60 |
|
| 61 | protected abstract Identifier getSlotSpriteLocation();
|
| 62 |
|
| 63 | protected abstract @Nullable Identifier getChestSlotsSpriteLocation();
|
| 64 |
|
| 65 | protected abstract boolean shouldRenderSaddleSlot();
|
| 66 |
|
| 67 | protected abstract boolean shouldRenderArmorSlot();
|
| 68 | }
|
| 69 |
|