I have been working on a custom overlay for my mod. It looks like this:
but when I open the escape menu it looks like this:
My code is this:
@OnlyIn(value = Dist.CLIENT)
public class ForcePowersOverlay {
private Minecraft minecraft;
private static final ResourceLocation tex = new ResourceLocation(Reference.MOD_ID, "textures/gui/mod_widgets.png");
public ForcePowersOverlay() {
minecraft = Minecraft.getInstance();
}
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
if(event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
renderCustomOverlay();
}
}
private void renderCustomOverlay(){
PlayerEntity player = (PlayerEntity)this.minecraft.getRenderViewEntity();
if (player != null) {
IForceSensitive data = player.getCapability(ModCapabilities.FORCE_CAPABILITY).orElseThrow(IllegalStateException::new);
int slotX = data.getSlot() * 20;
int scaledWidth = this.minecraft.getMainWindow().getScaledWidth();
int scaledHeight = this.minecraft.getMainWindow().getScaledHeight();
RenderSystem.pushMatrix();
RenderSystem.pushTextureAttributes();
RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();
RenderSystem.color4f(1F, 1F, 1F, 1F);
minecraft.getTextureManager().bindTexture(tex);
//Slots
minecraft.ingameGUI.blit(40, scaledHeight - 22, 0, 0, 62, 21);
//SelectedSlot
minecraft.ingameGUI.blit(40 + slotX, scaledHeight - 23, 62, 0, 24, 22);
//Push
minecraft.ingameGUI.blit(44, scaledHeight - 18, 4, 25, 15, 15);
//Epicenter
minecraft.ingameGUI.blit(64, scaledHeight - 18, 23, 25, 15, 15);
//Heal
minecraft.ingameGUI.blit(84, scaledHeight - 18, 42, 25, 15, 15);
//minecraft.getRenderManager().getFontRenderer().drawString(data.getSide().getName(), 8.0f, 6.0f, 410752);
minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
RenderSystem.popAttributes();
RenderSystem.popMatrix();
}
}
Any help would be great thanks.