Advertisement
HalestormXV

Pouch Screen

Jan 31st, 2021
1,392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.45 KB | None | 0 0
  1. package com.halestormxv.numinous.client.screens;
  2.  
  3. import com.halestormxv.numinous.NuminousMod;
  4. import com.halestormxv.numinous.common.containers.MaterialPouchContainer;
  5. import com.mojang.blaze3d.matrix.MatrixStack;
  6. import com.mojang.blaze3d.platform.GlStateManager;
  7. import com.mojang.blaze3d.systems.RenderSystem;
  8. import net.minecraft.client.gui.screen.inventory.ContainerScreen;
  9. import net.minecraft.entity.player.PlayerInventory;
  10. import net.minecraft.util.ResourceLocation;
  11. import net.minecraft.util.text.ITextComponent;
  12. import net.minecraft.util.text.TranslationTextComponent;
  13.  
  14. import java.awt.*;
  15.  
  16. public class MaterialPouchScreen extends ContainerScreen<MaterialPouchContainer> {
  17.     private static final ResourceLocation TEXTURE = new ResourceLocation(NuminousMod.MOD_ID,"textures/gui/material_pouch.png");
  18.  
  19.     private final PlayerInventory playerInventory;
  20.     private final int inventoryRows;
  21.  
  22.     public MaterialPouchScreen(MaterialPouchContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
  23.         super(screenContainer, inv, titleIn);
  24.         this.playerInventory = inv;
  25.         this.inventoryRows = screenContainer.getInventoryRows();
  26.     }
  27.  
  28.  
  29.     @Override
  30.     public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
  31.         this.renderBackground(matrixStack);
  32.         super.render(matrixStack, mouseX, mouseY, partialTicks);
  33.         this.renderHoveredTooltip(matrixStack, mouseX, mouseY);
  34.     }
  35.  
  36.     @Override
  37.     protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int mouseX, int mouseY) {
  38.         final float PLAYER_LABEL_XPOS = 8;
  39.         final float PLAYER_LABEL_DISTANCE_FROM_BOTTOM = (96 - 2);
  40.  
  41.         final float BAG_LABEL_YPOS = 6;
  42.         TranslationTextComponent bagLabel = new TranslationTextComponent("gui.material_pouch.title"); //StartupCommon.itemFlowerBag.getTranslationKey());
  43.         float BAG_LABEL_XPOS = (xSize / 2.0F) - this.font.getStringWidth(bagLabel.getString()) / 2.0F;                  // centre the label
  44.         this.font.func_243248_b(matrixStack, bagLabel, BAG_LABEL_XPOS, BAG_LABEL_YPOS, Color.darkGray.getRGB());            //this.font.drawString;
  45.  
  46.         float PLAYER_LABEL_YPOS = ySize - PLAYER_LABEL_DISTANCE_FROM_BOTTOM;
  47.         this.font.func_243248_b(matrixStack, this.playerInventory.getDisplayName(),                              //this.font.drawString;
  48.                 PLAYER_LABEL_XPOS, PLAYER_LABEL_YPOS, Color.darkGray.getRGB());
  49.     }
  50.  
  51.     @Override
  52.     protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int mouseX, int mouseY) {
  53.         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
  54.         this.minecraft.getTextureManager().bindTexture(TEXTURE);                //this.minecraft
  55.         // width and height are the size provided to the window when initialised after creation.
  56.         // xSize, ySize are the expected size of the texture-? usually seems to be left as a default.
  57.         // The code below is typical for vanilla containers, so I've just copied that- it appears to centre the texture within
  58.         //  the available window
  59.         int edgeSpacingX = (this.width - this.xSize) / 2;
  60.         int edgeSpacingY = (this.height - this.ySize) / 2;
  61.         this.blit(matrixStack, edgeSpacingX, edgeSpacingY, 0, 0, this.xSize, this.inventoryRows * 19 + 17);
  62.         this.blit(matrixStack, edgeSpacingX, edgeSpacingY + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
  63.     }
  64. }
  65.  
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement