RetroBuzz Posted December 3, 2024 Posted December 3, 2024 I can't seem to get anything to render on the screen. I have the mana working but can't make a bar or even just the int display. I am not good with rendering anything. Quote
Xoroshio Posted December 6, 2024 Posted December 6, 2024 What is your code for rendering the bar? Quote
RetroBuzz Posted December 6, 2024 Author Posted December 6, 2024 I tried a few different things that all didnt work. Right now I have nothing but what I had that seemed most likely to work was just a guiOverlay.blit(x, y, z, vx, vy, getMana()). I dont remember the exact code but it was somthing along those lines. It was in a new class extending screen I believe. Quote
RetroBuzz Posted December 6, 2024 Author Posted December 6, 2024 (edited) This is my latest attempt : public class ManaScreen extends Screen { Mana mana = new Mana(); boolean removeManaBar = false; ResourceLocation manaBar = ResourceLocation.fromNamespaceAndPath(RSGArmoury.MOD_ID, "/textures/block/spawnable_arena_wall.png"); public ManaScreen() { super(Component.literal("Mana")); } @Override protected void init() { super.init(); Minecraft.getInstance().setScreen(this); } @Override public boolean isPauseScreen() { return false; } @Override public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { pGuiGraphics.blit(manaBar, 10, -10, 0, 0, mana.getMana(), 10, mana.getMana(), 10); if (removeManaBar) { this.onClose(); return; } super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); } public void addManaBar() { removeManaBar = false; Minecraft.getInstance().setScreen(new ManaScreen()); } public boolean removeManaBar() { return removeManaBar = true; } } Edited December 6, 2024 by RetroBuzz Quote
Xoroshio Posted December 7, 2024 Posted December 7, 2024 You are creating an entire new screen, or GUI. What you probably want is an Overlay. Quote
Xoroshio Posted December 7, 2024 Posted December 7, 2024 If you want a mana GUI, call Minecraft.getInstance().setScreen(new ManaScreen()); somewhere display your GUI. I would recommend creating a keybind and listening to key events, and if your key bind is pressed down, running that code. Quote
RetroBuzz Posted December 8, 2024 Author Posted December 8, 2024 Ok, sounds like I would probably be best with a overlay then. I have also tried to make an event that setScreens when a magic item is pulled out and I think it actually crashed the game. Quote
Xoroshio Posted December 8, 2024 Posted December 8, 2024 If you set the screen when the item was pulled out that would make the item partially unusable. You can’t move in game when your screen isn’t null. Quote
RetroBuzz Posted December 9, 2024 Author Posted December 9, 2024 Ok, I see so a screen is only really useful for like a menu but would that explain the crashing? I haven't attempted making an overlay yet. By the way is there a way to get a notification from this site? I only check in every once in a while when I remember to see if there was an update. As I sent that it gave me a push notification pop up lol. Quote
Xoroshio Posted December 9, 2024 Posted December 9, 2024 To explain the crashing I need to see the log. Also, if you want to follow the topic just scroll to the top and click the following thing, and then press follow. And yes, screen are really only useful for menus and things. Quote
RetroBuzz Posted December 9, 2024 Author Posted December 9, 2024 This is what I have now, nothing shows on the screen and after using mana the game freezes. public class ManaOverlay extends Overlay { ResourceLocation manaBar = ResourceLocation.fromNamespaceAndPath(RSGArmoury.MOD_ID, "/textures/block/spawnable_arena_wall.png"); @Override public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { Mana mana = new Mana(); pGuiGraphics.blit(manaBar, 16, -16, 0, 0, mana.getMana(), 16, mana.getMana(), 16); } @Override public boolean isPauseScreen() { return false; } } Quote
Xoroshio Posted December 11, 2024 Posted December 11, 2024 How are you registering the overlay, and can I have the log. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.