Skip to content

Commit 06dbf58

Browse files
authored
MC 1.19.x Migration (#2)
* init (unstable) * init (unstable) * init * bumped version * bumped VR API to version with room data (stable-ish) * 0.3.0 * 0.3.0 (stable) refined things, improved config and simple tests, implemented speed and elapsed time
1 parent 590deb1 commit 06dbf58

31 files changed

Lines changed: 438 additions & 566 deletions

build.gradle

Lines changed: 69 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ buildscript {
77
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
88
}
99
}
10-
apply plugin: 'net.minecraftforge.gradle'
10+
1111
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
12-
apply plugin: 'eclipse'
13-
apply plugin: 'maven-publish'
12+
plugins {
13+
//In case people use the inferior IDE
14+
id 'eclipse'
15+
id 'maven-publish'
16+
}
1417

15-
version = '0.2.6'
18+
apply plugin: 'net.minecraftforge.gradle'
19+
version = '0.3.0'
1620
group = 'com.calicraft.vrjester' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1721
archivesBaseName = 'VRJesterAPI'
1822

19-
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
23+
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
24+
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
2025
project.logger.lifecycle("VRJesterAPI-${project.version}")
2126
project.logger.lifecycle('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
27+
2228
minecraft {
2329
// The mappings can be changed at any time, and must be in the following format.
2430
// Channel: Version:
@@ -31,10 +37,10 @@ minecraft {
3137
//
3238
// Use non-default mappings at your own risk. they may not always work.
3339
// Simply re-run your setup task after changing the mappings to update your workspace.
34-
mappings channel: 'official', version: '1.16.5'
40+
mappings channel: 'official', version: '1.19.2'
3541
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
36-
37-
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
42+
43+
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
3844

3945
// Default run configurations.
4046
// These can be tweaked, removed, or duplicated as needed.
@@ -54,6 +60,9 @@ minecraft {
5460
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
5561
property 'forge.logging.console.level', 'debug'
5662

63+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
64+
property 'forge.enabledGameTestNamespaces', 'vrjesterapi'
65+
5766
mods {
5867
vrjesterapi {
5968
source sourceSets.main
@@ -64,18 +73,31 @@ minecraft {
6473
server {
6574
workingDirectory project.file('run')
6675

67-
// Recommended logging data for a userdev environment
68-
// The markers can be changed as needed.
69-
// "SCAN": For mods scan.
70-
// "REGISTRIES": For firing of registry events.
71-
// "REGISTRYDUMP": For getting the contents of all registries.
7276
property 'forge.logging.markers', 'REGISTRIES'
7377

74-
// Recommended logging level for the console
75-
// You can set various levels here.
76-
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
7778
property 'forge.logging.console.level', 'debug'
7879

80+
property 'forge.enabledGameTestNamespaces', 'vrjesterapi'
81+
82+
mods {
83+
vrjesterapi {
84+
source sourceSets.main
85+
}
86+
}
87+
}
88+
89+
// This run config launches GameTestServer and runs all registered gametests, then exits.
90+
// By default, the server will crash when no gametests are provided.
91+
// The gametest system is also enabled by default for other run configs under the /test command.
92+
gameTestServer {
93+
workingDirectory project.file('run')
94+
95+
property 'forge.logging.markers', 'REGISTRIES'
96+
97+
property 'forge.logging.console.level', 'debug'
98+
99+
property 'forge.enabledGameTestNamespaces', 'vrjesterapi'
100+
79101
mods {
80102
vrjesterapi {
81103
source sourceSets.main
@@ -86,16 +108,8 @@ minecraft {
86108
data {
87109
workingDirectory project.file('run')
88110

89-
// Recommended logging data for a userdev environment
90-
// The markers can be changed as needed.
91-
// "SCAN": For mods scan.
92-
// "REGISTRIES": For firing of registry events.
93-
// "REGISTRYDUMP": For getting the contents of all registries.
94111
property 'forge.logging.markers', 'REGISTRIES'
95112

96-
// Recommended logging level for the console
97-
// You can set various levels here.
98-
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
99113
property 'forge.logging.console.level', 'debug'
100114

101115
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
@@ -118,39 +132,45 @@ task deobfJar(type: Jar) {
118132
classifier = 'deobf'
119133
}
120134

135+
repositories {
136+
// Put repositories for dependencies here
137+
// ForgeGradle automatically adds the Forge maven and Maven Central for you
138+
139+
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
140+
// flatDir {
141+
// dir 'lib'
142+
// }
143+
maven {
144+
url = "https://cursemaven.com"
145+
}
146+
mavenCentral()
147+
}
148+
121149
dependencies {
122-
implementation 'org.jetbrains:annotations:20.1.0'
123150

124151
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
125152
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
126153
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
127-
minecraft 'net.minecraftforge:forge:1.16.5-36.2.34'
128-
implementation files('libs/minecrift-1.16.5-jrbudda-7-6.jar')
129-
// implementation files('libs/vivecraft-1.19.2-jrbudda-VR-2-b8-forge.jar')
130-
implementation files('libs/OptiFine-1.16.5_HD_U_G8.jar')
131-
implementation group: 'org.json', name: 'json', version: '20220320'
132-
implementation group: 'io.github.classgraph', name: 'classgraph', version: '4.8.149'
133-
compileOnly group: 'com.mojang', name: 'authlib', version: '1.5.25'
154+
minecraft 'net.minecraftforge:forge:1.19.2-43.1.1'
155+
compileOnly fg.deobf("curse.maven:mcvrapi-591092:4073384")
156+
runtimeOnly fg.deobf("curse.maven:mcvrapi-591092:4073384")
157+
implementation 'org.jetbrains:annotations:23.0.0'
158+
implementation files('libs/OptiFine_1.19.2_HD_U_H9.jar')
159+
// implementation group: 'io.github.classgraph', name: 'classgraph', version: '4.8.149'
160+
// compileOnly group: 'com.mojang', name: 'authlib', version: '1.5.25'
134161

135162

136-
// You may put jars on which you depend on in ./libs or you may define them like so..
137-
// compile "some.group:artifact:version:classifier"
138-
// compile "some.group:artifact:version"
163+
// Real mod deobf dependency examples - these get remapped to your current mappings
164+
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
165+
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
166+
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
139167

140-
// Real examples
141-
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
142-
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
143-
144-
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
145-
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
146-
147-
// These dependencies get remapped to your current MCP mappings
148-
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
168+
// Examples using mod jars from ./libs
169+
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
149170

150171
// For more info...
151172
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
152173
// http://www.gradle.org/docs/current/userguide/dependency_management.html
153-
154174
}
155175

156176
// Example for how to get properties into the manifest for reading by the runtime..
@@ -193,3 +213,7 @@ publishing {
193213
}
194214
}
195215
}
216+
217+
tasks.withType(JavaCompile).configureEach {
218+
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
219+
}

forge-1.16.5-36.2.20-mdk.zip

-99.8 KB
Binary file not shown.

forge-1.19.2-43.1.1-mdk.zip

91.2 KB
Binary file not shown.

libs/OptiFine-1.16.5_HD_U_G8.jar

-3.13 MB
Binary file not shown.

libs/OptiFine_1.19.2_HD_U_H9.jar

6.55 MB
Binary file not shown.
-7.66 MB
Binary file not shown.
File renamed without changes.
Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
package com.calicraft.vrjester;
22

3-
import com.calicraft.vrjester.handlers.TriggerEventHandler;
4-
import com.calicraft.vrjester.tracker.PositionTracker;
53
import com.calicraft.vrjester.utils.tools.EventsLoader;
6-
import net.minecraft.block.Block;
7-
import net.minecraft.block.Blocks;
4+
import net.minecraft.client.KeyMapping;
85
import net.minecraft.client.Minecraft;
9-
import net.minecraft.client.settings.KeyBinding;
6+
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
107
import net.minecraftforge.common.MinecraftForge;
11-
import net.minecraftforge.event.RegistryEvent;
8+
import net.minecraftforge.event.server.ServerStartingEvent;
9+
import net.minecraftforge.eventbus.api.IEventBus;
1210
import net.minecraftforge.eventbus.api.SubscribeEvent;
1311
import net.minecraftforge.fml.InterModComms;
14-
import net.minecraftforge.fml.client.registry.ClientRegistry;
1512
import net.minecraftforge.fml.common.Mod;
1613
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
1714
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
1815
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
1916
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
20-
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
2117
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
2218
import org.apache.logging.log4j.LogManager;
2319
import org.apache.logging.log4j.Logger;
@@ -28,35 +24,25 @@
2824
@Mod("vrjester")
2925
public class VrJesterApi {
3026
// Main entry point
31-
private static final Logger LOGGER = LogManager.getLogger();
32-
public static PositionTracker TRACKER;
27+
public static final Logger LOGGER = LogManager.getLogger();
3328
public static boolean VIVECRAFTLOADED = false;
3429
public static final String MOD_ID = "vrjester";
35-
public static final KeyBinding MOD_KEY = new KeyBinding("Jester Trigger", 71, MOD_ID);
30+
public static final KeyMapping MOD_KEY = new KeyMapping("key.vrjester.71", 71, MOD_ID);
3631

3732
public VrJesterApi() {
33+
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
34+
3835
// Register the setup method for modloading
3936
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
4037
// Register the enqueueIMC method for modloading
4138
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
4239
// Register the processIMC method for modloading
4340
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
44-
// Register the doClientStuff method for modloading
45-
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
41+
// Register the registerBindings method for modloading
42+
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerBindings);
4643
// Register ourselves for server and other game events we are interested in
4744
MinecraftForge.EVENT_BUS.register(this);
48-
// Register deferred register for custom particles
49-
// PARTICLES.register(FMLJavaModLoadingContext.get().getModEventBus());
50-
try { // Check if Vivecraft is running
51-
Class.forName("org.vivecraft.api.VRData");
52-
VIVECRAFTLOADED = true;
53-
System.out.println("Vivecraft has been loaded!");
54-
EventsLoader.register();
55-
LOGGER.info("Events have been loaded!");
56-
} catch (ClassNotFoundException | NoClassDefFoundError e) {
57-
LOGGER.error("Vivecraft has failed to load!");
58-
}
59-
MinecraftForge.EVENT_BUS.register(new TriggerEventHandler());
45+
EventsLoader.register();
6046
}
6147

6248
public static Minecraft getMCI() {
@@ -65,9 +51,7 @@ public static Minecraft getMCI() {
6551

6652
private void setup(final FMLCommonSetupEvent event) {
6753
// some preinit code
68-
ClientRegistry.registerKeyBinding(MOD_KEY);
6954
LOGGER.info("HELLO FROM PREINIT");
70-
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
7155
}
7256

7357
private void enqueueIMC(final InterModEnqueueEvent event) {
@@ -78,29 +62,37 @@ private void enqueueIMC(final InterModEnqueueEvent event) {
7862
private void processIMC(final InterModProcessEvent event) {
7963
// some example code to receive and process InterModComms from other mods
8064
LOGGER.info("Got IMC {}", event.getIMCStream().
81-
map(m->m.getMessageSupplier().get()).
65+
map(m->m.messageSupplier().get()).
8266
collect(Collectors.toList()));
8367
}
8468

8569
private void doClientStuff(final FMLClientSetupEvent event) {
8670
// do something that can only be done on the client
87-
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().options);
71+
LOGGER.info("Do client stuff like get game settings");
8872
}
73+
74+
public void registerBindings(RegisterKeyMappingsEvent event) {
75+
LOGGER.info("Registering KeyMappings");
76+
event.register(MOD_KEY);
77+
}
78+
8979
// You can use SubscribeEvent and let the Event Bus discover methods to call
9080
@SubscribeEvent
91-
public void onServerStarting(FMLServerStartingEvent event) {
92-
// do something when the server starts
81+
public void onServerStarting(ServerStartingEvent event) {
82+
// Do something when the server starts
9383
LOGGER.info("HELLO from server starting");
9484
}
9585

96-
// You can use EventBusSubscriber to automatically subscribe events on the contained class
97-
// (this is subscribing to the MOD Event bus for receiving Registry Events)
98-
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
99-
public static class RegistryEvents {
86+
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
87+
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
88+
public static class ClientModEvents
89+
{
10090
@SubscribeEvent
101-
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
102-
// register a new block here
103-
LOGGER.info("HELLO from Register Block");
91+
public static void onClientSetup(FMLClientSetupEvent event)
92+
{
93+
// Some client setup code
94+
LOGGER.info("HELLO FROM CLIENT SETUP");
95+
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
10496
}
10597
}
10698
}
Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
package com.calicraft.vrjester.config;
22

3-
import org.json.JSONObject;
3+
import com.google.gson.Gson;
4+
import com.google.gson.GsonBuilder;
45

56
import java.io.File;
67
import java.io.FileNotFoundException;
7-
import java.io.IOException;
8-
import java.nio.file.Files;
9-
import java.nio.file.Path;
108
import java.util.Scanner;
119

1210
public class Config {
11+
public boolean WRITE_DATA = Constants.WRITE_DATA;
12+
public boolean DISPLAY_VOX = Constants.DISPLAY_VOX;
13+
public float VOX_LENGTH = Constants.VOX_LENGTH;
14+
public int VOX_GRID_LENGTH = Constants.VOX_GRID_LENGTH;
15+
public int VOX_GRID_WIDTH = Constants.VOX_GRID_WIDTH;
16+
public int VOX_GRID_HEIGHT = Constants.VOX_GRID_HEIGHT;
17+
public float MAX_LISTENING_TIME = Constants.MAX_LISTENING_TIME;
18+
public SimpleGesture[] GESTURES;
19+
public Log LOG;
20+
21+
public class Log {
22+
// Class that represents log configuration
23+
public String name;
24+
public String gesture;
25+
public int pose;
26+
public String[] devices;
27+
}
1328

14-
public String configPath = Constants.CONFIG_PATH;
15-
16-
public Config() {}
17-
18-
public Config(String configPath) {
19-
this.configPath = configPath;
29+
public class SimpleGesture {
30+
// Class that represents a gesture's overall simple attributes from a collection of Trace objects
31+
public String name;
32+
public String movements;
33+
public long elapsedTime;
34+
public double velocity;
2035
}
2136

22-
public JSONObject readConfig() {
37+
public static Config readConfig(String configPath) {
2338
try {
2439
StringBuilder sb = new StringBuilder();
2540
File configFile = new File(configPath);
@@ -30,17 +45,15 @@ public JSONObject readConfig() {
3045
// System.out.println("CONFIG: " + data);
3146
}
3247
myReader.close();
33-
return new JSONObject(sb.toString());
34-
// return new JSONObject(Files.readString(Path.of(configPath)));
48+
GsonBuilder builder = new GsonBuilder();
49+
builder.setPrettyPrinting();
50+
Gson gson = builder.create();
51+
Config configJson = gson.fromJson(sb.toString(), Config.class);
52+
return configJson;
3553
} catch (FileNotFoundException e) {
36-
System.out.println("An error occurred!");
54+
System.out.println("An error occurred reading config json!");
3755
e.printStackTrace();
3856
}
39-
// } catch (IOException e) {
40-
// System.out.println("An error occurred!");
41-
// e.printStackTrace();
42-
// }
43-
return new JSONObject();
57+
return new Config();
4458
}
45-
4659
}

0 commit comments

Comments
 (0)