123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package me.km.networking;
- import com.mojang.blaze3d.matrix.MatrixStack;
- import com.mojang.blaze3d.systems.RenderSystem;
- import me.km.KajetansMod;
- import me.km.inventory.CustomContainer;
- import me.km.inventory.ModInventory;
- import net.minecraft.client.gui.screen.inventory.ContainerScreen;
- import net.minecraft.entity.player.PlayerInventory;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.text.ITextComponent;
- import net.minecraftforge.api.distmarker.Dist;
- import net.minecraftforge.api.distmarker.OnlyIn;
- @OnlyIn(Dist.CLIENT)
- public class CustomInventoryScreen extends ContainerScreen<CustomContainer> {
- private static final ResourceLocation CHEST_GUI_TEXTURE =
- new ResourceLocation("textures/gui/container/generic_54.png");
- private static final ResourceLocation EMPTY_TILE =
- new ResourceLocation(KajetansMod.MODID, "textures/gui/container/empty_tile.png");
- private final int inventoryRows;
- public CustomInventoryScreen(CustomContainer cc, PlayerInventory pInv, ITextComponent title) {
- super(cc, pInv, title);
- passEvents = false;
- inventoryRows = cc.getInventoryBase().getRows();
- imageHeight = 114 + inventoryRows * 18;
- }
- @Override
- public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
- this.renderBackground(matrixStack);
- super.render(matrixStack, mouseX, mouseY, partialTicks);
- this.renderTooltip(matrixStack, mouseX, mouseY);
- }
- @Override
- protected void renderLabels(MatrixStack matrixStack, int x, int y) {
- this.font.draw(matrixStack, title.getString(), 8.0f, 6.0f, 4210752);
- this.font.draw(matrixStack, inventory.getDisplayName().getString(), 8.0f, imageHeight - 94,
- 4210752);
- }
- @SuppressWarnings("deprecation")
- @Override
- protected void renderBg(MatrixStack matrixStack, float partialTicks, int ix, int iy) {
- RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
- this.minecraft.getTextureManager().bind(CHEST_GUI_TEXTURE);
- int i = (width - imageWidth) / 2;
- int j = (height - imageHeight) / 2;
- blit(matrixStack, i, j, 0, 0, imageWidth, inventoryRows * 18 + 17);
- blit(matrixStack, i, j + inventoryRows * 18 + 17, 0, 126, imageWidth, 96);
- i += 7;
- j += 17;
- minecraft.getTextureManager().bind(EMPTY_TILE);
- ModInventory base = this.getMenu().getInventoryBase();
- for(int x = 0; x < 9; x++) {
- for(int y = 0; y < inventoryRows; y++) {
- if(base.shouldRenderOverlay(x, y)) {
- blit(matrixStack, i + 18 * x, j + 18 * y, 0, 0, 18, 18, 64, 64);
- } else if(base.shouldRenderDarker(x, y)) {
- blit(matrixStack, i + 18 * x, j + 18 * y, 18, 0, 18, 18, 64, 64);
- }
- }
- }
- }
- }
|