-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #170
- Loading branch information
Showing
19 changed files
with
196 additions
and
159 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
platform/fabric/src/main/java/mcp/mobius/waila/fabric/FabricClientService.java
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
platform/fabric/src/main/resources/META-INF/services/mcp.mobius.waila.service.IClientService
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
platform/forge/src/main/java/mcp/mobius/waila/forge/ForgeClientService.java
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
platform/forge/src/main/resources/META-INF/services/mcp.mobius.waila.service.IClientService
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
platform/neo/src/main/java/mcp/mobius/waila/neo/NeoClientService.java
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
platform/neo/src/main/resources/META-INF/services/mcp.mobius.waila.service.IClientService
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
platform/quilt/src/main/java/mcp/mobius/waila/quilt/QuiltClientService.java
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
platform/quilt/src/main/resources/META-INF/services/mcp.mobius.waila.service.IClientService
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package mcp.mobius.waila.config; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.Map; | ||
|
||
import com.google.common.collect.MapMaker; | ||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonParseException; | ||
import com.google.gson.JsonPrimitive; | ||
import com.google.gson.JsonSerializationContext; | ||
import com.google.gson.JsonSerializer; | ||
import com.mojang.blaze3d.platform.InputConstants; | ||
import net.minecraft.client.Minecraft; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public final class KeyBinding { | ||
|
||
private static final Map<InputConstants.Key, KeyBinding> INSTANCES = new MapMaker().weakValues().makeMap(); | ||
|
||
public static final KeyBinding UNKNOWN = of(InputConstants.UNKNOWN); | ||
|
||
private final InputConstants.Key key; | ||
|
||
private @Nullable Boolean pressed; | ||
private @Nullable Boolean wasPressed; | ||
private boolean held; | ||
|
||
private KeyBinding(InputConstants.Key key) { | ||
this.key = key; | ||
} | ||
|
||
public static KeyBinding of(InputConstants.Key key) { | ||
return INSTANCES.computeIfAbsent(key, KeyBinding::new); | ||
} | ||
|
||
public boolean isDown() { | ||
if (pressed == null) { | ||
pressed = key.getValue() != InputConstants.UNKNOWN.getValue() | ||
&& InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), key.getValue()); | ||
|
||
if (!pressed) { | ||
held = false; | ||
} else { | ||
held = wasPressed == Boolean.TRUE; | ||
} | ||
} | ||
|
||
return pressed; | ||
} | ||
|
||
public boolean isPressed() { | ||
isDown(); | ||
return pressed == Boolean.TRUE && !held; | ||
} | ||
|
||
public static void tick() { | ||
for (var instance : INSTANCES.values()) { | ||
instance.wasPressed = instance.pressed; | ||
instance.pressed = null; | ||
} | ||
} | ||
|
||
public InputConstants.Key key() { | ||
return key; | ||
} | ||
|
||
public static class Adapter implements JsonSerializer<KeyBinding>, JsonDeserializer<KeyBinding> { | ||
|
||
@Override | ||
public KeyBinding deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||
return of(InputConstants.getKey(json.getAsString())); | ||
} | ||
|
||
@Override | ||
public JsonElement serialize(KeyBinding src, Type typeOfSrc, JsonSerializationContext context) { | ||
return new JsonPrimitive(src.key.getName()); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.