This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dispatch to InputEvents from patchwork-god-classes (#130)
* Move InputEvent firing to a new class, InputEvents * Dispatch from ForgeHooksClient to InputEvents * Fixup! mixin didn't actually implement interface.
- Loading branch information
Showing
7 changed files
with
131 additions
and
25 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
patchwork-events-input/src/main/java/net/patchworkmc/api/input/ForgeMouse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Minecraft Forge, Patchwork Project | ||
* Copyright (c) 2016-2020, 2019-2020 | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation version 2.1 | ||
* of the License. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
package net.patchworkmc.api.input; | ||
|
||
public interface ForgeMouse { | ||
boolean isMiddleDown(); | ||
double getXVelocity(); | ||
double getYVelocity(); | ||
} |
48 changes: 48 additions & 0 deletions
48
patchwork-events-input/src/main/java/net/patchworkmc/impl/event/input/InputEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Minecraft Forge, Patchwork Project | ||
* Copyright (c) 2016-2020, 2019-2020 | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation version 2.1 | ||
* of the License. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
package net.patchworkmc.impl.event.input; | ||
|
||
import net.minecraftforge.client.event.InputEvent; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.eventbus.api.Event; | ||
|
||
import net.minecraft.client.Mouse; | ||
|
||
import net.patchworkmc.api.input.ForgeMouse; | ||
|
||
public class InputEvents { | ||
public static void fireMouseInput(int button, int action, int mods) { | ||
MinecraftForge.EVENT_BUS.post(new InputEvent.MouseInputEvent(button, action, mods)); | ||
} | ||
|
||
public static void fireKeyInput(int key, int scanCode, int action, int modifiers) { | ||
MinecraftForge.EVENT_BUS.post(new InputEvent.KeyInputEvent(key, scanCode, action, modifiers)); | ||
} | ||
|
||
public static boolean onMouseScroll(Mouse mouseHelper, double scrollDelta) { | ||
final Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.wasLeftButtonClicked(), ((ForgeMouse) mouseHelper).isMiddleDown(), mouseHelper.wasRightButtonClicked(), mouseHelper.getX(), mouseHelper.getY()); | ||
|
||
return MinecraftForge.EVENT_BUS.post(event); | ||
} | ||
|
||
public static boolean onRawMouseClicked(int button, int action, int mods) { | ||
return MinecraftForge.EVENT_BUS.post(new InputEvent.RawMouseEvent(button, action, mods)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters