-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix non-conflicting key mappings still taking priority on Fabric…
… without amecs TwelveIterationMods/InventoryEssentials#19 TwelveIterationMods/InventoryEssentials#20
- Loading branch information
1 parent
76bde0e
commit 1674cb2
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
fabric/src/main/java/net/blay09/mods/balm/mixin/FabricKeyMappingMixin.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,40 @@ | ||
package net.blay09.mods.balm.mixin; | ||
|
||
import com.mojang.blaze3d.platform.InputConstants; | ||
import net.blay09.mods.balm.api.client.BalmClient; | ||
import net.minecraft.client.KeyMapping; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(KeyMapping.class) | ||
public class FabricKeyMappingMixin { | ||
|
||
@Final | ||
@Shadow | ||
private static Map<InputConstants.Key, KeyMapping> MAP; | ||
|
||
@ModifyArg(method = "<init>(Ljava/lang/String;Lcom/mojang/blaze3d/platform/InputConstants$Type;ILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 1), index = 1) | ||
private Object ctor(Object key, Object value) { | ||
if (value instanceof KeyMapping keyMapping) { | ||
if (key instanceof InputConstants.Key && BalmClient.getKeyMappings().shouldIgnoreConflicts(keyMapping)) { | ||
return MAP.get(key); | ||
} | ||
} | ||
return value; | ||
} | ||
|
||
@ModifyArg(method = "resetMapping()V", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), index = 1) | ||
private static Object resetMappings(Object key, Object value) { | ||
if (value instanceof KeyMapping keyMapping) { | ||
if (key instanceof InputConstants.Key && BalmClient.getKeyMappings().shouldIgnoreConflicts(keyMapping)) { | ||
return MAP.get(key); | ||
} | ||
} | ||
return value; | ||
} | ||
} |
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