Skip to content

Commit 549277a

Browse files
committed
Fix #1
1 parent 1c01a13 commit 549277a

5 files changed

Lines changed: 48 additions & 17 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.1
99
loader_version=0.14.22
1010

1111
# Mod Properties
12-
mod_version=0.4.0
12+
mod_version=0.4.1
1313
maven_group=com.provismet
1414
archives_base_name=vmc-mc
1515

src/main/java/com/provismet/vmcmc/config/ClothVMC.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public static Screen build (Screen parent) {
3131
.build()
3232
);
3333

34+
general.addEntry(entryBuilder.startBooleanToggle(Text.translatable("entry.vmcmc.general.compat_identifiers"), Config.shouldUseCompatibilityIds())
35+
.setDefaultValue(false)
36+
.setTooltip(Text.translatable("tooltip.vmcmc.general.compat_identifiers"))
37+
.setSaveConsumer(newValue -> Config.setCompatibilityIdMode(newValue))
38+
.build()
39+
);
40+
3441
builder.setSavingRunnable(() -> {
3542
Config.saveJSON();
3643
PacketSender.initPort(Config.getIP(), Config.getPort());

src/main/java/com/provismet/vmcmc/config/Config.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
import com.provismet.vmcmc.ClientVMC;
99
import com.provismet.vmcmc.vmc.PacketSender;
1010

11+
import net.minecraft.util.Identifier;
1112
import net.minecraft.util.Pair;
1213

1314
public class Config {
1415
private static final String HOST = "host";
1516
private static final String PORT = "port";
17+
private static final String COMPAT_IDENTIFIERS_LABEL = "compatibility_identifiers";
1618
private static final String FILEPATH = "config/vmc-mc.json";
1719

20+
private static boolean useCompatIds = false;
1821
private static String host = PacketSender.LOCALHOST;
1922
private static int port = PacketSender.DEFAULT_PORT;
2023

@@ -35,6 +38,10 @@ public static Pair<String,Integer> readJSON () {
3538
port = parser.nextInt();
3639
break;
3740

41+
case COMPAT_IDENTIFIERS_LABEL:
42+
useCompatIds = parser.nextBoolean();
43+
break;
44+
3845
default:
3946
break;
4047
}
@@ -45,20 +52,21 @@ public static Pair<String,Integer> readJSON () {
4552
catch (FileNotFoundException e) {
4653
ClientVMC.LOGGER.warn("Config not found, creating default config.");
4754
saveJSON();
48-
return new Pair<String,Integer>(PacketSender.LOCALHOST, PacketSender.DEFAULT_PORT);
55+
return new Pair<>(PacketSender.LOCALHOST, PacketSender.DEFAULT_PORT);
4956
}
5057
catch (Exception e) {
5158
ClientVMC.LOGGER.warn("Config could not be read, using default parameters.", e);
52-
return new Pair<String,Integer>(PacketSender.LOCALHOST, PacketSender.DEFAULT_PORT);
59+
return new Pair<>(PacketSender.LOCALHOST, PacketSender.DEFAULT_PORT);
5360
}
5461
}
5562

5663
public static void saveJSON () {
5764
try {
5865
FileWriter writer = new FileWriter(FILEPATH);
59-
String simpleJSON = String.format("{\n\t\"%s\": \"%s\",\n\t\"%s\": %d\n}",
66+
String simpleJSON = String.format("{\n\t\"%s\": \"%s\",\n\t\"%s\": %d,\n\t\"%s\": %b\n}",
6067
HOST, host,
61-
PORT, port
68+
PORT, port,
69+
COMPAT_IDENTIFIERS_LABEL, useCompatIds
6270
);
6371
writer.write(simpleJSON);
6472
writer.close();
@@ -68,6 +76,19 @@ public static void saveJSON () {
6876
}
6977
}
7078

79+
public static boolean shouldUseCompatibilityIds () {
80+
return useCompatIds;
81+
}
82+
83+
public static void setCompatibilityIdMode (boolean shouldUseCompat) {
84+
useCompatIds = shouldUseCompat;
85+
}
86+
87+
public static String getBlendName (Identifier blendshape) {
88+
if (useCompatIds) return blendshape.toString().replace(':', '_');
89+
return blendshape.toString();
90+
}
91+
7192
public static String getIP () {
7293
return host;
7394
}

src/main/java/com/provismet/vmcmc/vmc/CaptureRegistry.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.illposed.osc.OSCPacket;
99
import com.provismet.vmcmc.ClientVMC;
10+
import com.provismet.vmcmc.config.Config;
1011
import com.provismet.vmcmc.utility.HealthTracker;
1112

1213
import net.fabricmc.api.EnvType;
@@ -33,28 +34,28 @@ public class CaptureRegistry {
3334
private static final HashMap<String, BlendStore> BLENDSTORE_REGISTRY = new HashMap<>();
3435

3536
public static BlendStore getBlendStore (Identifier identifier) {
36-
return BLENDSTORE_REGISTRY.get(identifier.toString());
37+
return BLENDSTORE_REGISTRY.get(Config.getBlendName(identifier));
3738
}
3839

3940
public static boolean containsKey (String key) {
4041
return BLEND_REGISTRY.containsKey(key) || BLENDSTORE_REGISTRY.containsKey(key) || BONE_REGISTRY.containsKey(key);
4142
}
4243

4344
public static boolean containsKey (Identifier key) {
44-
return containsKey(key.toString());
45+
return containsKey(Config.getBlendName(key));
4546
}
4647

4748
/**
4849
* Registers a callback that generates a BlendShape. Minecraft identifiers are used to softly-enforce unique names.
49-
*
50-
* It is recommend, but not required, that callbacks have their output bound between 0 and 1.
50+
* <p>
51+
* It is recommended, but not required, that callbacks have their output bound between 0 and 1.
5152
*
5253
* @param identifier The ID for the BlendShape. Note: This will be converted into a string when being sent over OSC.
5354
* @param callback A function that uses the client to output a float.
5455
*/
5556
public static void registerBlendShape (Identifier identifier, Function<MinecraftClient, Float> callback) {
56-
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendShape register attempt: " + identifier.toString());
57-
else BLEND_REGISTRY.put(identifier.toString(), callback);
57+
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendShape register attempt: " + Config.getBlendName(identifier));
58+
else BLEND_REGISTRY.put(Config.getBlendName(identifier), callback);
5859
}
5960

6061
/**
@@ -72,21 +73,21 @@ public static void registerBlendShape (String path, Function<MinecraftClient, Fl
7273
* @param blendStore The BlendStore to receive input from.
7374
*/
7475
public static void registerBlendStore (Identifier identifier, BlendStore blendStore) {
75-
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendStore register attempt: " + identifier.toString());
76-
else BLENDSTORE_REGISTRY.put(identifier.toString(), blendStore);
76+
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendStore register attempt: " + Config.getBlendName(identifier));
77+
else BLENDSTORE_REGISTRY.put(Config.getBlendName(identifier), blendStore);
7778
}
7879

7980
public static void registerBlendStore (String path, BlendStore blendStore) {
8081
registerBlendStore(ClientVMC.identifier(path), blendStore);
8182
}
8283

8384
/**
84-
* NOTE: BONES ARE CURRENTLY NON-FUNCTIONAL. USE BLENDSHAPES INSTEAD.
85-
*
8685
* Registers a callback that generates a Bone.
8786
* Bones are defined as 7 floats (a 3D coordinate and a quaternion).
8887
* {@code [x coordinate, y coordinate, z coordinate, quaternion-x, quaternion-y, quaternion-z, quaternion-w]}
89-
*
88+
*
89+
* @implNote BONES ARE CURRENTLY NON-FUNCTIONAL. USE BLENDSHAPES INSTEAD.
90+
*
9091
* @param identifier The ID for the Bone. Note: This will be converted into a string when being sent over OSC.
9192
* @param callback A function that uses the client to output a list of floats.
9293
*/

src/main/resources/assets/vmcmc/lang/en_us.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
"tooltip.vmcmc.general.ip": "Must be a valid IP address. e.g. 127.0.0.1",
77
"tooltip.vmcmc.general.port": "Must be a value between 1 and 65535.",
8+
"tooltip.vmcmc.general.compat_identifiers": "Replaces colons with underscores for compatibility with certain vtubing software. Requires restart.",
89

910
"entry.vmcmc.general.ip": "IP Address",
10-
"entry.vmcmc.general.port": "Port"
11+
"entry.vmcmc.general.port": "Port",
12+
"entry.vmcmc.general.compat_identifiers": "Compatibility BlendShape Names"
1113
}

0 commit comments

Comments
 (0)