Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

mohkamfer

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

mohkamfer's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Well I could do that, however I'm concerned that running a check every tick could harm performance. Could there possibly be a better way to schedule a task to run once, and then not to bother every single tick after? Just like we can post a Runnable using a Handler.
  2. Well aside from commands, what about the guiScreen not showing up? I already match a command string and what's missing is showing it
  3. I made a screen extending Screen, and am trying to show it when a certain [client-side] event occurs. I do Minecraft.getInstance().displayGuiScreen(new ...) but nothing shows. I made sure the code actually reaches that line, but then it goes absolutely silent. I'm trying to call it in a ClientChatEvent listener. Backstory I'm trying to listen for a /commandString message sent by the player, show my screen then cancel the event. I had to use this dirty workaround since commands worked on single player only. Not sure if mentioning this could provide better support, but here we go. EDIT: The Screen has nothing to do with the server. I listen for client events only. Not sure what's happening. I've seen some other threads, but they all 'suggest' that it should work on client just fine if it doesn't communicate with the server. If looking at vanilla code could help me, all I am seeing is Minecraft#displayGuiScreen() calls just like what I'm trying to do. Not sure why it isn't considered as a client-side call to it -- if this is even the problem. ANOTHER EDIT: Yes, it worked with commands registered on server starting event. If anybody would wonder.
  4. Yeah I was successfully able to draw it on top of the current GuiScreen using events. The only problem facing me now is that tooltips appear behind my component.. Is there any way to only redraw the tooltips of the container? Or maybe draw my component just before tooltips are drawn?
  5. Well, being introduced to the forge documentation (which seems to not help in any way at all) for the first time today explains why I messed up so bad... So which event exactly should I listen to? GuiScreenEvent from net.minecraftforge.client.event? Also once I get its instance, do I attach the the text field only? Or I make a complete GuiScreen for it? In both cases how do I dynamically attach a view to that instance? I tried looking up JEI's repository, but they already have a sophisticated architecture with many middlewares between what I want to look at, so it's quite hard to learn anything from it. If there's a simpler plugin that I could look at its source code, I'd be much appreciated so I don't annoy you with questions.
  6. @Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION) public class ExampleMod { class ContainerOpenEventHandler { @SubscribeEvent public void containerOpen(PlayerContainerEvent.Open containerEvent) { Minecraft.getMinecraft().displayGuiScreen(new InputScreen()); } } class InputScreen extends GuiScreen { private GuiTextField textField; private int textFieldId; @Override public void initGui() { super.initGui(); textFieldId = 0; textField = new GuiTextField(textFieldId, fontRenderer, 0, 0, 100, 10); Keyboard.enableRepeatEvents(true); } @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); textField.textboxKeyTyped(typedChar, keyCode); } @Override public void updateScreen() { super.updateScreen(); textField.updateCursorCounter(); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); textField.drawTextBox(); // I shuffled this before and after super, didn't help. } @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); textField.mouseClicked(mouseX, mouseY, mouseButton); } @Override protected void actionPerformed(GuiButton button) throws IOException { super.actionPerformed(button); } @Override public boolean doesGuiPauseGame() { return false; } } public static final String MODID = "example"; public static final String NAME = "Example"; public static final String VERSION = "1.0"; private static Logger logger; @EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); } @EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new ContainerOpenEventHandler()); } } Also I tried showing the screen after closing the container, just to confirm... And it showed perfectly... So this makes me believe that the container GUI is overriding my screen GUI, how can I force draw the textbox over the container?
  7. Hello, I'm trying to draw a GuiScreen over a normal container like a chest for example, but seems like the textbox is only being shown for one frame, and the rest of the frames the cursor is hidden and the textbox is invisible. How can I achieve such a combination? Just like how JEI shows the items list on the right, and a textbox underneath. As for my code, it's really simple and basic, that I don't think might be introducing a problem, and I believe my problem is something missing not something existing.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.