|
1 | 1 | package mezz.jei.fabric.input;
|
2 | 2 |
|
3 | 3 | import com.mojang.blaze3d.platform.InputConstants;
|
4 |
| -import java.util.function.Consumer; |
5 |
| -import mezz.jei.common.input.keys.IJeiKeyMappingInternal; |
6 | 4 | import mezz.jei.common.input.keys.JeiKeyConflictContext;
|
7 |
| -import mezz.jei.common.input.keys.JeiKeyModifier; |
8 |
| -import net.minecraft.client.KeyMapping; |
9 |
| -import net.minecraft.network.chat.Component; |
10 | 5 |
|
11 |
| -public class FabricJeiKeyMapping implements IJeiKeyMappingInternal { |
12 |
| - private final String category; |
13 |
| - private final String description; |
14 |
| - private final JeiKeyConflictContext context; |
15 |
| - private final JeiKeyModifier modifier; |
16 |
| - private final InputConstants.Type type; |
17 |
| - private final InputConstants.Key key; |
| 6 | +public class FabricJeiKeyMapping extends AbstractJeiKeyMapping { |
| 7 | + protected final FabricKeyMapping fabricMapping; |
18 | 8 |
|
19 |
| - public FabricJeiKeyMapping( |
20 |
| - String category, |
21 |
| - String description, |
22 |
| - JeiKeyConflictContext context, |
23 |
| - JeiKeyModifier modifier, |
24 |
| - InputConstants.Type type, |
25 |
| - int keyCode |
26 |
| - ) { |
27 |
| - this.category = category; |
28 |
| - this.description = description; |
29 |
| - this.context = context; |
30 |
| - this.modifier = modifier; |
31 |
| - this.type = type; |
32 |
| - this.key = type.getOrCreate(keyCode); |
| 9 | + public FabricJeiKeyMapping(FabricKeyMapping fabricMapping, JeiKeyConflictContext context) { |
| 10 | + super(context); |
| 11 | + this.fabricMapping = fabricMapping; |
33 | 12 | }
|
34 | 13 |
|
35 |
| - @Override |
36 |
| - public boolean isActiveAndMatches(InputConstants.Key key) { |
37 |
| - if (isUnbound()) { |
38 |
| - return false; |
39 |
| - } |
40 |
| - if (!this.key.equals(key)) { |
41 |
| - return false; |
42 |
| - } |
43 |
| - return context.isActive() && modifier.isActive(context); |
| 14 | + protected FabricKeyMapping getMapping() { |
| 15 | + return this.fabricMapping; |
44 | 16 | }
|
45 | 17 |
|
46 |
| - @Override |
47 |
| - public boolean isUnbound() { |
48 |
| - return this.key.equals(InputConstants.UNKNOWN); |
49 |
| - } |
50 |
| - |
51 |
| - @Override |
52 |
| - public Component getTranslatedKeyMessage() { |
53 |
| - return modifier.getCombinedName(key); |
54 |
| - } |
55 |
| - |
56 |
| - @Override |
57 |
| - public IJeiKeyMappingInternal register(Consumer<KeyMapping> registerMethod) { |
58 |
| - return this; |
| 18 | + protected InputConstants.Key getMappedKey() { |
| 19 | + return this.fabricMapping.realKey; |
59 | 20 | }
|
60 | 21 | }
|
0 commit comments