-
Posts
10 -
Joined
-
Last visited
Everything posted by bboc
-
I've registered my command with that and the GUI is working wonderfully, thank you sm.
-
As an alternative should I just add a check in the chat message sent event? Is there an alternative way to add a client side command?
-
I think you're right? Though honestly I'm not certain. What I've got is: @EventHandler public void serverLoad(FMLServerStartingEvent event) { event.registerServerCommand(new HudOpener()); }
-
I don't see why either tbh. I'm currently in the process of rewriting everything from the ground up, because my previous code was very hacky and rushed, but to maybe stop this from happening again; here's the way that I was calling the GuiScreen, perhaps the issue lies in there? package pvphud.main; import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; public class HudOpener extends CommandBase { @Override public String getName() { return "pvphud"; } @Override public String getUsage(ICommandSender sender) { return "pvphud"; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { Minecraft.getMinecraft().displayGuiScreen(new PVPHudOptions()); } }
-
package pvphud.main; import java.io.IOException; import org.lwjgl.input.Mouse; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import pvphud.main.KeyStrokes.ColorChoice; public class PVPHudOptions extends GuiScreen { private GuiButton colorButton; private GuiButton cornerButton; @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); } @Override public boolean doesGuiPauseGame() { return false; } @Override public void initGui() { this.buttonList.add(this.colorButton = new GuiButton(0, this.width / 2 - 100, this.height / 2 - 24, "Color Choice: " + KeyStrokes.chosenColor)); this.buttonList.add(this.cornerButton = new GuiButton(1, this.width / 2 - 100, this.height / 2 + 4, "Corner Choice: " + KeyStrokes.chosenCorner)); } @Override protected void actionPerformed(GuiButton button) throws IOException { if (button == this.colorButton) { int colorInt = KeyStrokes.chosenColor.ordinal(); colorInt ++; if(colorInt >= KeyStrokes.ColorChoice.values().length) { colorInt = 0; } KeyStrokes.setColorChoice(KeyStrokes.ColorChoice.values()[colorInt]); this.buttonList.set(0, this.colorButton = new GuiButton(0, this.width / 2 - 100, this.height / 2 - 24, "Color Choice: " + KeyStrokes.chosenColor)); } if (button == this.cornerButton){ int cornerInt = KeyStrokes.chosenCorner.ordinal(); cornerInt ++; if(cornerInt >= KeyStrokes.Corner.values().length) { cornerInt = 0; } KeyStrokes.setCornerChoice(KeyStrokes.Corner.values()[cornerInt]); this.buttonList.set(1, this.cornerButton = new GuiButton(1, this.width / 2 - 100, this.height / 2 + 4, "Corner Choice: " + KeyStrokes.chosenCorner)); } } }
-
Aight, I’ll be at my computer in ~2 hrs, I’ll post it then
-
You're absolutely right. I'm just not thinking through this stuff right or something rn. Regardless, I've replaced the re-adding with .set, so now it just updates the button. Beyond that, I still need to render the mouse, and my original guess of mc.mousehelper.ungrabMouseCursor() doesn't seem to work. *EDIT Through using Mouse.setGrabbed(false) I can allow myself to click the buttons, but for some reason it's very sporadic and only lets me sometimes click them.
-
Sorry fam, I'm really just tryna learn by doing here, I needed the buttons' contents to update depending on what option they had chosen, and despite being ghetto that seemed like a working way to do it. What method do you suggest to make sure the button contents are constantly updated? *Edit NVM That was stupid I can just re-add the button I should have thought that through more. The issue still stands however, I can't get the mouse to render.
-
I recently wrote a GuiScreen to change options in my mod, which works just fine, but the mouse doesn't show. Here is the GuiScreen which opens: package pvphud.main; import java.io.IOException; import org.lwjgl.input.Mouse; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; import pvphud.main.KeyStrokes.ColorChoice; public class PVPHudOptions extends GuiScreen { private GuiButton colorButton; private GuiButton cornerButton; @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); } @Override public boolean doesGuiPauseGame() { return false; } @Override public void initGui() { this.fontRenderer.drawString("QXB Strokes!", this.width / 2 - 100, this.height / 2 - 48, 0xFFFFFFFF); this.buttonList.add(this.colorButton = new GuiButton(0, this.width / 2 - 100, this.height / 2 - 24, "Color Choice: " + KeyStrokes.chosenColor)); this.buttonList.add(this.cornerButton = new GuiButton(1, this.width / 2 - 100, this.height / 2 + 4, "Corner Choice: " + KeyStrokes.chosenCorner)); } @Override protected void actionPerformed(GuiButton button) throws IOException { if (button == this.colorButton) { int colorInt = KeyStrokes.chosenColor.ordinal(); colorInt ++; if(colorInt >= KeyStrokes.ColorChoice.values().length) { colorInt = 0; } KeyStrokes.setColorChoice(KeyStrokes.ColorChoice.values()[colorInt]); } if (button == this.cornerButton){ int cornerInt = KeyStrokes.chosenCorner.ordinal(); cornerInt ++; if(cornerInt >= KeyStrokes.Corner.values().length) { cornerInt = 0; } KeyStrokes.setCornerChoice(KeyStrokes.Corner.values()[cornerInt]); } } @Override public void updateScreen() { this.initGui(); } @Override public void onGuiClosed() { } }
-
Currently I'm writing a mod that will simply display the keystrokes of the player on the screen. I'm using the renderGameOverlay event, and filtering out the event if it's not the crosshair being rendered. This works fine, but the crosshair stops being rendered entirely. Is there any way for me to keep the current context of a certain event on top of the content I want to add? Code: @SubscribeEvent public void renderString(RenderGameOverlayEvent event) { GuiIngame guiTool = Minecraft.getMinecraft().ingameGUI; if (event.getType() != ElementType.CROSSHAIRS) { return; } if(Minecraft.getMinecraft().gameSettings.keyBindForward.isKeyDown()) { guiTool.drawRect(300, 100, 320, 120, 0x60FFFFFF); guiTool.drawString(guiTool.getFontRenderer(), "W", 307, 107, 0xFF000000); } else { guiTool.drawRect(300, 100, 320, 120, 0x60000000); guiTool.drawString(guiTool.getFontRenderer(), "W", 307, 107, 0xFFFFFFFF); } }