Created
May 6, 2022 17:42
-
-
Save gamma-02/96f50eae873dcaf77a360b61a09d715e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import [...] | |
public class CleanerScreen extends AbstractContainerScreen<CleanerMenu> { | |
private static final ResourceLocation TEXTURE = resource("textures/gui/cleaning_station.png"); | |
private static final int progressBarXOffset = 176; | |
private static final int progressBarYOffset = 14; | |
private static final int fluidBarXOffset = 177; | |
private static final int fluidBarYOffset = 81;//move this DOWN | |
public CleanerScreen(CleanerMenu pMenu, Inventory pPlayerInventory, Component pTitle) { | |
super(pMenu, pPlayerInventory, pTitle); | |
this.itemRenderer = Minecraft.getInstance().getItemRenderer(); | |
// BlockEntity tempOwner = pPlayerInventory.player.getCommandSenderWorld().getBlockEntity( pPlayerInventory.player.getCommandSenderWorld().clip(new ClipContext( pPlayerInventory.player.getLookAngle(), pPlayerInventory.player.getLookAngle().add(5, 5, 5), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, pPlayerInventory.player)).getBlockPos()); | |
// pMenu.setInstance(tempOwner instanceof CleanerBlockEntity ? (CleanerBlockEntity) tempOwner : null); | |
} | |
public CleanerScreen(CleanerMenu menu, Inventory inv, Component title, BlockEntity entity){ | |
super(menu, inv, title); | |
this.itemRenderer = Minecraft.getInstance().getItemRenderer(); | |
this.minecraft = Minecraft.getInstance(); | |
this.itemRenderer = minecraft.getItemRenderer(); | |
this.font = minecraft.font; | |
if(entity instanceof CleanerBlockEntity e) | |
menu.setInstance(e); | |
} | |
@Override | |
protected void renderBg(PoseStack pPoseStack, float pPartialTick, int pMouseX, int pMouseY) { | |
RenderSystem.setShader(GameRenderer::getPositionTexShader); | |
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); | |
RenderSystem.setShaderTexture(0, TEXTURE); | |
int i = this.leftPos; | |
int j = this.topPos; | |
this.blit(pPoseStack, i, j, 0, 0, 175, 165); | |
boolean isInstanceNull = menu.isInstanceNull(); | |
//render progress bar | |
if(!isInstanceNull && this.menu.isCleaning()){ | |
int progress = menu.getProgress(); | |
this.blit(pPoseStack, 78, 34, progressBarXOffset, progressBarYOffset, progress, 16/*or 17 if it doesn't work thats why*/); | |
} | |
//render fluid amount | |
if(!isInstanceNull && this.menu.getAmountOfFluid() > 0){ | |
int fluidHeight = this.menu.getAmountOfFluid()/49; | |
this.blit(pPoseStack, 47, 68, fluidBarXOffset, fluidBarYOffset, 4, fluidHeight); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment