-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added mouse input handler and key input handle for JemiRecipe #319
Conversation
It is a bit silly that it was never implemented. However, I don't really want to add and expose an API like this on DrawableWidget. It'd be fine to just create a new widget for JEMI input events that doesn't render anything. |
Well, I made this code based on how you made DrawableWidget. I saw that you were creating a Consumer and decided to do it in the same style. |
Just if I understand you correctly, you want to create two widgets on top of each other, only one will be with a render, and the other without. |
I was suggesting leaving the drawable widget as it is, and adding a new widget, even just an anonymous or internal class, that just handles the input events. Thinking about it though, a new custom widget class (inside JemiRecipe) that handles rendering, tooltips, and input events for the JEMI display would probably be reasonable. |
I did as you said. Check it out. |
emi/xplat/src/main/java/dev/emi/emi/jemi/JemiRecipe.java Lines 153 to 160 in 54b0490
why are you creating a second |
because it is done in the original logic. I don't want to break anything... |
I removed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the comment I have it looks good to me. Have you tested this with mods that use JEI's input features to make sure it works?
public boolean keyPressed(int keyCode, int scanCode, int modifiers) { | ||
MinecraftClient client = MinecraftClient.getInstance(); | ||
double mouseX = client.mouse.getX() * (double)client.getWindow().getScaledWidth() / (double)client.getWindow().getWidth(); | ||
double mouseY = client.mouse.getY() * (double)client.getWindow().getScaledHeight() / (double)client.getWindow().getHeight(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to use EmiScreenManager.lastMouseX
and EmiScreenManager.lastMouseY
just to reduce the use of calculations.
Initially, I discovered this problem when using the CustomMachinery mod and after these changes, the click in JEI began to work normally for CM. In general, I think it will work fine. |
I don't know for what reason it wasn't implemented, but due to the absence of this code, JEI recipes don't handle clicks and keystrokes.