Jump to content

How to get what a player is typing before they send it


AyyyyLmao

Recommended Posts

I don't think there is hook for before sending anything.

 

Depending how autocorrecting your autocorrect will be you might do some tricks.

 

Minecraft client knows current Gui opened. (mc.currentScreen).

There is ClientTickEvent that is fired by FML client-side every phase: START and END of tick (choose one always).

You can check if gui instanceof GuiChat and get currently written text box and apply autocorrect, problem is you would need to do it in some tricky way to not interfere with player's input. (Obviously not every tick).

 

If you can't think of a way to do it (I can, but don't know what are you planning) then you are left with implementing custom GuiChat (there is also GuiChatNew, look it up) and using GuiOpenEvent - replace GuiChat with yours. (better way I think, if you are planning that big feature, yet - more coding).

 

EDIT

Obviously, you can also use other events - Input events, e.g "click 'Insert' to check spelling".

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

EDIT

Obviously, you can also use other events - Input events, e.g "click 'Insert' to check spelling".

 

Actually, I don't think you can. Last time I tried I think I found that input events aren't fired when chat gui is open.

 

I think your suggestion about using tick event is probably better.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I don't think there is hook for before sending anything.

 

Depending how autocorrecting your autocorrect will be you might do some tricks.

 

Minecraft client knows current Gui opened. (mc.currentScreen).

There is ClientTickEvent that is fired by FML client-side every phase: START and END of tick (choose one always).

You can check if gui instanceof GuiChat and get currently written text box and apply autocorrect, problem is you would need to do it in some tricky way to not interfere with player's input. (Obviously not every tick).

 

If you can't think of a way to do it (I can, but don't know what are you planning) then you are left with implementing custom GuiChat (there is also GuiChatNew, look it up) and using GuiOpenEvent - replace GuiChat with yours. (better way I think, if you are planning that big feature, yet - more coding).

 

EDIT

Obviously, you can also use other events - Input events, e.g "click 'Insert' to check spelling".

 

I was thinking of having a guibutton popup above the word as you're typing it and that way if you spelled the word incorrectly and want to correct it you can click the button that you want.

I'm interested in hearing what you had in mind though. If you would like to tell me that is, I don't mind :>

Link to comment
Share on other sites

That would be actually possible without overriding whole Gui.

Right now I can think of at least few different combinations of tools that would allow you to do it.

 

1. Replace GuiChat with your own Chat - do whatever you want then (literally, whatever).

* Use GuiOpenEvent to check if event.gui is chat, and open other (your gui).

- Requires knowledge about coding Gui.

 

2. Utilize few hooks to do it.

* Use ClientTickeEvent

- Save String with text typed in chat in last tick. If the text changed in current tick (lower that to e.g 20 ticks for performance), scan changed string and pull out all new-typed words (so that you won't have to auto-correct ones that were typed before), make shitload of String operations and autocorrect stuff. Replace word with corrected string and set chat field to edited string.

* Use mc.currentScreen (inside TickEvent from above) - get buttonList from current GuiChat and add new Button to every new-typed word. You can easily put that button e.g above the word.

* You can use FontRenderer to get length of given text.

* Adding button will do nothing - you just added it, now you need to add action to it:

Use ActionPerformedEvent, check if clicked button is your new button - perform auto-correcting. Then you can remove that button.

 

The actual problem is that last time I was doing stuff (I replaced GuiChat) in this field was year ago or more. Things might have changed, what I am not sure of is the fact if you can actually add/remove button in any moment.

 

Pretty much all I can tell, lookup net.minecraftforge.client.event if you are looking for something more.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • so i just got this crash report and i dont mod a lot so i literally have no idea what to do to fix this
    • Hello, I was trying to play a MOD in my preferred language, but I see that only some items are translated, and I go to debug and I get this information (the only thing that is translated is the bestiary):   [14sep.2024 17:14:36.415] [Render thread/WARN] [net.minecraft.client.resources.language.ClientLanguage/]: Skipped language file: mowziesmobs:lang/es_es.json (com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected name at line 394 column 2 path $.config.mowziesmobs.ice_crystal_attack_multiplier) [14sep.2024 17:14:36.421] [Render thread/WARN] [net.minecraft.client.resources.language.ClientLanguage/]: Skipped language file: iceandfire:lang/es_es.json (com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1349 column 4 path $.iceandfire.sound.subtitle.dragonflute)   Is that the reason why everything is not translated? , and is there any way to fix it? Thanks
    • I got my model to render from the models renderToBuffer method. But still not quite what I want. I want to render the model from my renderer's render method. I feel that having access to the renderer and its methods will open some doors for me later down the line. //EntityRendererProvider.Context pContext = ; I want this //ToaPlayerRenderer render = new ToaPlayerRenderer(pContext, false); // if I can get the above line to work, having the methods from the renderer class would be incredibly helpful down the line RenderType rendertype = model.renderType(p.getSkinTextureLocation()); // this should be something like render.getTextureLocation() VertexConsumer vertexconsumer = buffer.getBuffer(rendertype); model.renderToBuffer(stack, vertexconsumer, paLights, 1, 1, 1, 1, 1); // I don't want the render to happen here since it doesn't use the renderer //model.render(p, 1f, pTicks, stack, buffer, paLights); I want to render the model using this It is certainly getting closer though. Probably. I am still worried that even if pContext is initialized this new instance of the renderer class will still hit me with the classic and all too familiar "can't use static method in non-static context"
    • Hello, I am learning how to create Multipart Entities and I tried creating a PartEntity based on the EnderDragonPart code. However, when I tested summoning the entity in the game, the PartEntity appeared at position x 0, y 0, z 0 within the game. I tried to make it follow the main entity, and after testing again, the part entity followed the main entity but seemed to teleport back to x 0, y 0, z 0 every tick (I'm just guessing). I don't know how to fix this can someone help me? My github https://github.com/SteveKK666/Forge-NewWorld-1.20.1/tree/master/src/main/java/net/kk/newworldmod/entity/custom Illustration  https://drive.google.com/file/d/157SPvyQCE8GcsRXyQQkD4Dyhalz6LjBn/view?usp=drive_link Sorry for my English; I’m not very good at it. 
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.