generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
19 deletions.
There are no files selected for viewing
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,41 @@ | ||
package com.provismet.vmcmc.config; | ||
|
||
import com.provismet.vmcmc.vmc.PacketSender; | ||
|
||
import me.shedaniel.clothconfig2.api.ConfigBuilder; | ||
import me.shedaniel.clothconfig2.api.ConfigCategory; | ||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.text.Text; | ||
|
||
public class ClothVMC { | ||
public static Screen build (Screen parent) { | ||
ConfigBuilder builder = ConfigBuilder.create(); | ||
builder.setParentScreen(parent); | ||
builder.setTitle(Text.translatable("title.vmcmc.config")); | ||
|
||
ConfigCategory general = builder.getOrCreateCategory(Text.translatable("category.vmcmc.general")); | ||
ConfigEntryBuilder entryBuilder = builder.entryBuilder(); | ||
|
||
general.addEntry(entryBuilder.startStrField(Text.translatable("entry.vmcmc.general.ip"), Config.getIP()) | ||
.setDefaultValue(PacketSender.LOCALHOST) | ||
.setTooltip(Text.translatable("tooltip.vmcmc.general.ip")) | ||
.setSaveConsumer(newValue -> Config.setIP(newValue)) | ||
.build() | ||
); | ||
|
||
general.addEntry(entryBuilder.startIntField(Text.translatable("entry.vmcmc.general.port"), Config.getPort()) | ||
.setDefaultValue(PacketSender.DEFAULT_PORT) | ||
.setTooltip(Text.translatable("tooltip.vmcmc.general.port")) | ||
.setSaveConsumer(newValue -> Config.setPort(newValue)) | ||
.build() | ||
); | ||
|
||
builder.setSavingRunnable(() -> { | ||
Config.saveJSON(); | ||
PacketSender.initPort(Config.getIP(), Config.getPort()); | ||
}); | ||
|
||
return builder.build(); | ||
} | ||
} |
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,18 @@ | ||
package com.provismet.vmcmc.config; | ||
|
||
import com.terraformersmc.modmenu.api.ConfigScreenFactory; | ||
import com.terraformersmc.modmenu.api.ModMenuApi; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
public class ModMenuHook implements ModMenuApi { | ||
@Override | ||
public ConfigScreenFactory<?> getModConfigScreenFactory () { | ||
if (FabricLoader.getInstance().isModLoaded("cloth-config")) { | ||
return parent -> { | ||
return ClothVMC.build(parent); | ||
}; | ||
} | ||
else return parent -> null; | ||
} | ||
} |
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,11 @@ | ||
{ | ||
"title.vmcmc.config": "Virtual Motion Capture", | ||
|
||
"category.vmcmc.general": "General", | ||
|
||
"tooltip.vmcmc.general.ip": "Must be a valid IP address. e.g. 127.0.0.1", | ||
"tooltip.vmcmc.general.port": "Must be a value between 1 and 65535.", | ||
|
||
"entry.vmcmc.general.ip": "IP Address", | ||
"entry.vmcmc.general.port": "Port" | ||
} |
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