Skip to content

Commit 96c1cbd

Browse files
authored
Savestate fixes (#214)
## Changes - [Savestates] Fix loading savestates across dimensions failing on the first try - [Gui] Readded keystrokes to the gui - [FileCommands] Added more precision to desyncMonitor - [Gui] Changed DesyncMonitor values from relative to absolute - Added hash to dev-build filename and ingame hud - Removed "savestates are broken" warnings from the chat - [Savestates] Switched to Paths instead of Files - [Savestates|Config] Reworked Config and other files - [Savestates] Switched from storing motion in the playerdata to storing motion in `World/tasmod/clientMotion.json` - [Gui] Removed "TASmod is still in development! Major issues may arise!" message in gui screens - [PlaybackSerialiser] Loads of fixes to integrate better with savestates - [VirtualInput] Fixed player being able to turn during playback - [Savestates] Fix scoreboard not being applied - [Savestates] Fix some redstone components behaving weirdly
2 parents 0a38f1a + 528331e commit 96c1cbd

File tree

70 files changed

+3249
-1678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3249
-1678
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Gradle
2020
uses: gradle/actions/setup-gradle@v3
2121
with:
22-
gradle-version: 8.6
22+
gradle-version: 8.10.2
2323
- name: Build TASmod with Gradle
2424
run: gradle build
2525
- name: Upload Test Report

.github/workflows/buildandupload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Gradle
2121
uses: gradle/actions/setup-gradle@v3
2222
with:
23-
gradle-version: 8.6
23+
gradle-version: 8.10.2
2424
- name: Build TASmod with Gradle
2525
run: gradle build
2626
- name: Upload artifact

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Create Release
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Setup Java
11+
uses: actions/setup-java@v4
12+
with:
13+
java-version: '22'
14+
distribution: 'temurin'
15+
architecture: x64
16+
- name: Setup Gradle
17+
uses: gradle/actions/setup-gradle@v4
18+
with:
19+
gradle-version: 8.10.2
20+
- name: Setup workspace
21+
run: gradle build -Prelease=true
22+
- name: Upload assets
23+
uses: softprops/action-gh-release@v2
24+
with:
25+
files: 'build/libs/!(-@(dev|sources|javadoc|all)).jar'
26+
- name: Publish 1.12.2
27+
uses: Kir-Antipov/[email protected]
28+
with:
29+
files: 'build/libs/*-1.12.2-*!(*-@(dev|sources|javadoc|all)).jar'
30+
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
31+
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

build.gradle

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@ plugins {
33
id 'fabric-loom' version "${loom_version}"
44
// legacy looming (loom plugin improvements)
55
id 'legacy-looming' version "${loom_version}"
6+
id 'com.palantir.git-version' version '3.1.0'
67
}
78

89

910
// set basic properties
10-
version = project.version
11+
def hash = ""
12+
if(project.release=="false") {
13+
hash = "-SNAPSHOT_"+versionDetails().gitHash.substring(0,7)
14+
}
15+
version = project.version+hash
1116
group = project.group
1217

13-
// compile for java 8
14-
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
18+
java {
19+
// compile for java 8
20+
sourceCompatibility = targetCompatibility = 8
21+
}
1522

1623
loom {
1724
// set access widener
1825
accessWidenerPath = file('src/main/resources/tasmod.accesswidener')
1926
// add log4jconfig
2027
log4jConfigs.from(file('src/main/resources/log4j.xml'))
21-
2228
}
2329

2430
// dependency repositories
@@ -52,8 +58,6 @@ dependencies {
5258
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
5359
}
5460

55-
56-
5761
// task for downloading KillTheRng
5862
//task downloadKTRNG(type: Copy) {
5963
//group 'tasmod'
@@ -62,15 +66,15 @@ dependencies {
6266
//into 'run/mods/'
6367
//}
6468

65-
compileJava{
69+
compileJava {
6670
options.release = 8
6771
}
6872

6973
// process fabric mod json
7074
processResources {
7175
inputs.property "version", project.version
7276
inputs.property "mcversion", project.minecraft_version
73-
77+
7478
filesMatching("fabric.mod.json") {
7579
expand 'mod_url': project.mod_url, 'name': project.mod_name, 'mod_version': project.version, 'mod_description': project.mod_description, 'mod_sources': project.mod_sources, 'mod_email': project.mod_email
7680
}

gradle.properties

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx3G
33

44
# Fabric properties
55
minecraft_version=1.12.2
6-
loader_version=0.15.9
7-
loom_version=1.6-SNAPSHOT
6+
loader_version=0.16.9
7+
loom_version=1.8-SNAPSHOT
88

99
# Mod properties
1010
mod_name=Tool-Assisted Speedrun Mod
@@ -16,4 +16,5 @@ [email protected]
1616
# TASmod properties
1717
group=com.minecrafttas
1818
artifact=TASmod-1.12.2
19-
version=Beta1.0-SNAPSHOT
19+
version=Beta1.0
20+
release=false
Lines changed: 23 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,45 @@
11
package com.minecrafttas.mctcommon;
22

3-
import java.io.File;
4-
import java.io.FileInputStream;
5-
import java.io.FileNotFoundException;
6-
import java.io.FileOutputStream;
7-
import java.io.IOException;
8-
import java.util.ArrayList;
9-
import java.util.InvalidPropertiesFormatException;
10-
import java.util.LinkedHashMap;
11-
import java.util.List;
3+
import java.nio.file.Files;
4+
import java.nio.file.Path;
125
import java.util.Properties;
136

14-
import com.minecrafttas.mctcommon.Configuration.ConfigOptions;
15-
import com.minecrafttas.mctcommon.registry.AbstractRegistry;
16-
import com.minecrafttas.mctcommon.registry.Registerable;
7+
import com.minecrafttas.mctcommon.ConfigurationRegistry.ConfigOptions;
8+
import com.minecrafttas.mctcommon.file.AbstractDataFile;
179

1810
/**
1911
* A <i>very</i> simple configuration class
2012
*
2113
* @author Scribble
2214
*/
2315

24-
public class Configuration extends AbstractRegistry<ConfigOptions> {
16+
public class Configuration extends AbstractDataFile {
2517

26-
private File file;
18+
private ConfigurationRegistry registry;
2719

28-
private Properties properties;
29-
30-
private String comment;
31-
32-
public Configuration(String comment, File configFile) {
33-
super("Configuration", new LinkedHashMap<>());
34-
35-
file = configFile;
36-
this.comment = comment;
20+
public Configuration(String comment, Path configFile, ConfigurationRegistry registry) {
21+
super(configFile, "config", comment);
22+
this.registry = registry;
3723
}
3824

39-
protected final List<ConfigOptions> configRegistry = new ArrayList<>();
40-
4125
@Override
42-
public void register(ConfigOptions registryObject) {
43-
if(registryObject == null) {
44-
return;
45-
}
46-
47-
if(configRegistry.contains(registryObject)) {
48-
return;
49-
}
50-
51-
configRegistry.add(registryObject);
52-
}
53-
54-
@Override
55-
public void unregister(ConfigOptions registryObject) {
56-
if (registryObject == null) {
57-
return;
58-
}
59-
60-
if (!configRegistry.contains(registryObject)) {
61-
return;
62-
}
63-
64-
configRegistry.remove(registryObject);
65-
}
66-
67-
public void load() {
68-
if (file.exists()) {
69-
properties = loadInner();
26+
public void loadFromXML() {
27+
if (Files.exists(file)) {
28+
loadFromXML(file);
7029
}
71-
if (properties == null || !file.exists()) {
30+
if (properties == null || !Files.exists(file)) {
7231
properties = generateDefault();
73-
save();
74-
}
75-
}
76-
77-
private Properties loadInner() {
78-
FileInputStream fis;
79-
Properties newProp = new Properties();
80-
try {
81-
fis = new FileInputStream(file);
82-
newProp.loadFromXML(fis);
83-
fis.close();
84-
} catch (InvalidPropertiesFormatException e) {
85-
MCTCommon.LOGGER.error("The config file could not be read", e);
86-
return null;
87-
} catch (FileNotFoundException e) {
88-
MCTCommon.LOGGER.warn("No config file found: {}", file);
89-
return null;
90-
} catch (IOException e) {
91-
MCTCommon.LOGGER.error("An error occured while reading the config", e);
92-
return null;
93-
}
94-
return newProp;
95-
}
96-
97-
public void save() {
98-
save(file);
99-
}
100-
101-
public void save(File file) {
102-
try {
103-
FileOutputStream fos = new FileOutputStream(file);
104-
properties.storeToXML(fos, comment, "UTF-8");
105-
fos.close();
106-
} catch (IOException e) {
107-
e.printStackTrace();
32+
saveToXML();
10833
}
10934
}
11035

36+
/**
37+
* Generates the default property list from the values provided in {@link #registry}
38+
* @return The default property list
39+
*/
11140
public Properties generateDefault() {
11241
Properties newProperties = new Properties();
113-
configRegistry.forEach((configOption)->{
42+
registry.getConfigRegistry().forEach((configOption) -> {
11443
newProperties.put(configOption.getConfigKey(), configOption.getDefaultValue());
11544
});
11645
return newProperties;
@@ -121,6 +50,7 @@ public String get(ConfigOptions configOption) {
12150
}
12251

12352
public int getInt(ConfigOptions configOption) {
53+
// TODO Add config exception or something... NumberFormatExceptions all around...
12454
return Integer.parseInt(get(configOption));
12555
}
12656

@@ -133,11 +63,11 @@ public boolean has(ConfigOptions configOption) {
13363
}
13464

13565
public void set(ConfigOptions configOption, String value) {
136-
if(properties == null) {
66+
if (properties == null) {
13767
throw new NullPointerException("Config needs to be loaded first, before trying to set a value");
13868
}
13969
properties.setProperty(configOption.getConfigKey(), value);
140-
save();
70+
saveToXML();
14171
}
14272

14373
public void set(ConfigOptions configOption, int value) {
@@ -156,13 +86,6 @@ public void reset(ConfigOptions configOption) {
15686

15787
public void delete(ConfigOptions configOption) {
15888
properties.remove(configOption);
159-
save();
160-
}
161-
162-
public interface ConfigOptions extends Registerable {
163-
164-
public String getDefaultValue();
165-
166-
public String getConfigKey();
89+
saveToXML();
16790
}
16891
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.minecrafttas.mctcommon;
2+
3+
import java.util.ArrayList;
4+
import java.util.LinkedHashMap;
5+
import java.util.List;
6+
7+
import com.minecrafttas.mctcommon.ConfigurationRegistry.ConfigOptions;
8+
import com.minecrafttas.mctcommon.registry.AbstractRegistry;
9+
import com.minecrafttas.mctcommon.registry.Registerable;
10+
11+
public class ConfigurationRegistry extends AbstractRegistry<ConfigOptions> {
12+
13+
protected final List<ConfigOptions> configRegistry = new ArrayList<>();
14+
15+
public ConfigurationRegistry() {
16+
super("Configuration", new LinkedHashMap<>());
17+
}
18+
19+
@Override
20+
public void register(ConfigOptions registryObject) {
21+
if (registryObject == null) {
22+
return;
23+
}
24+
25+
if (configRegistry.contains(registryObject)) {
26+
return;
27+
}
28+
29+
configRegistry.add(registryObject);
30+
}
31+
32+
@Override
33+
public void unregister(ConfigOptions registryObject) {
34+
if (registryObject == null) {
35+
return;
36+
}
37+
38+
if (!configRegistry.contains(registryObject)) {
39+
return;
40+
}
41+
42+
configRegistry.remove(registryObject);
43+
}
44+
45+
public List<ConfigOptions> getConfigRegistry() {
46+
return configRegistry;
47+
}
48+
49+
/**
50+
* <p>Interface for registering your own options in the TASmod config
51+
*
52+
* @see com.minecrafttas.tasmod.registries.TASmodConfig TASmodConfig
53+
* @author Scribble
54+
*/
55+
public interface ConfigOptions extends Registerable {
56+
/**
57+
* @return The config key name that is stored in the file
58+
*/
59+
public String getConfigKey();
60+
61+
/**
62+
* @return The default value that is used if the config key doesn't exist yet
63+
*/
64+
public String getDefaultValue();
65+
}
66+
}

src/main/java/com/minecrafttas/mctcommon/MCTCommon.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
public class MCTCommon {
99
public static final Logger LOGGER = LogManager.getLogger("MCTCommon");
10-
10+
1111
public static final Marker Event = MarkerManager.getMarker("Event");
12-
12+
1313
public static final Marker Server = MarkerManager.getMarker("Server");
14-
14+
1515
public static final Marker Client = MarkerManager.getMarker("Client");
16-
16+
1717
public static final Marker Timeout = MarkerManager.getMarker("Timeout");
1818

1919
}

0 commit comments

Comments
 (0)