Skip to content

Commit faba71e

Browse files
committed
Remove patch meant for an older version of Hypertale that caused issues!
+ Some goodies for Hypertale Plus
1 parent cba2b19 commit faba71e

12 files changed

Lines changed: 111 additions & 116 deletions

File tree

launcher/src/main/java/com/fox2code/hypertale/io/HypertaleData.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
public final class HypertaleData {
3030
// Note: We don't need backward compatibility for the format version,
3131
// since if the format version is different, other fields would be different too.
32-
private static final int HYPERTALE_CACHE_FORMAT_VERSION = 1;
32+
private static final int HYPERTALE_CACHE_FORMAT_VERSION = 2;
3333
private final int hypertaleCacheFormatVersion;
3434
public long hypertaleJarSize;
3535
public long originalJarSize;
3636
public long modifiedJarSize;
3737
public int patchConfigFlags;
3838
public int modHash;
3939
public long prePatcherSize;
40+
public int hypertalePlus;
4041

4142
public HypertaleData(File file) throws IOException {
4243
try (DataInputStream dataInputStream = new DataInputStream(
@@ -53,6 +54,7 @@ public HypertaleData(File file) throws IOException {
5354
this.patchConfigFlags = dataInputStream.readInt();
5455
this.modHash = dataInputStream.readInt();
5556
this.prePatcherSize = dataInputStream.readLong();
57+
this.hypertalePlus = dataInputStream.readInt();
5658
}
5759
}
5860
}
@@ -64,6 +66,7 @@ public HypertaleData() {
6466
this.modifiedJarSize = 0;
6567
this.patchConfigFlags = 0;
6668
this.modHash = 0;
69+
this.hypertalePlus = 0;
6770
}
6871

6972
public void writeTo(File file) throws IOException {
@@ -79,6 +82,7 @@ public void writeTo(File file) throws IOException {
7982
dataOutputStream.writeInt(this.patchConfigFlags);
8083
dataOutputStream.writeInt(this.modHash);
8184
dataOutputStream.writeLong(this.prePatcherSize);
85+
dataOutputStream.writeInt(this.hypertalePlus);
8286
}
8387
}
8488

@@ -91,14 +95,15 @@ public boolean equals(Object obj) {
9195
this.modifiedJarSize == hypertaleData.modifiedJarSize &&
9296
this.patchConfigFlags == hypertaleData.patchConfigFlags &&
9397
this.modHash == hypertaleData.modHash &&
94-
this.prePatcherSize == hypertaleData.prePatcherSize;
98+
this.prePatcherSize == hypertaleData.prePatcherSize &&
99+
this.hypertalePlus == hypertaleData.hypertalePlus;
95100
}
96101

97102
@Override
98103
public int hashCode() {
99104
return Objects.hash(this.hypertaleCacheFormatVersion,
100105
this.hypertaleJarSize, this.originalJarSize,
101106
this.modifiedJarSize, this.patchConfigFlags, this.modHash,
102-
this.prePatcherSize);
107+
this.prePatcherSize, this.hypertalePlus);
103108
}
104109
}

launcher/src/main/java/com/fox2code/hypertale/launcher/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ static void main(String[] args) throws IOException, InterruptedException {
233233
actualData.modHash = modGatherer.getModHash();
234234
actualData.prePatcherSize = HypertalePaths.hypertalePrePatcher.isFile() ?
235235
HypertalePaths.hypertalePrePatcher.length() : 0;
236+
actualData.hypertalePlus = MainPlus.hypertalePlusValue();
236237
if (args.length == 1 && "--dry".equals(args[0])) {
237238
return;
238239
}

launcher/src/main/java/com/fox2code/hypertale/launcher/MainPlus.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ static boolean forceOffline() {
6969
// Hypertale Offline Edition overwrite this method
7070
return false;
7171
}
72+
73+
public static int hypertalePlusValue() {
74+
return 0;
75+
}
7276
}

patcher/src/main/java/com/fox2code/hypertale/loader/HypertaleConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public final class HypertaleConfig {
4848
public static boolean premiumHyperOptimizeClassPath = false; // Optimize the entire classpath as a whole
4949
public static boolean premiumCheckJarValidity = true; // Check if the patched jar bytecode is valid before starting
5050
public static boolean premiumOfflineMode = false; // Disable the ability for plugins to connect to the internet
51+
public static boolean proAutoInhibitFix = true; // Make Hypertale query online for resources
5152
public static int watchdogWarnLagAfter = 10; // Time after which a stacktrace will be dumped
5253
public static int watchdogExitAfter = 60; // Time after which hypertale assume the server crashed
5354

@@ -181,4 +182,8 @@ public static boolean isUnsupportedConfiguration() {
181182
public static boolean isOfflineMode() {
182183
return PREMIUM && HypertaleConfig.premiumOfflineMode;
183184
}
185+
186+
public static boolean isInhibitFix() {
187+
return PREMIUM && HypertaleConfig.proAutoInhibitFix;
188+
}
184189
}

patcher/src/main/java/com/fox2code/hypertale/patcher/HypertaleASMConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public interface HypertaleASMConstants {
7575
String FloodLightCalculation = "com/hypixel/hytale/server/core/universe/world/lighting/FloodLightCalculation";
7676
String FullBrightLightCalculation = "com/hypixel/hytale/server/core/universe/world/lighting/FullBrightLightCalculation";
7777
String ChunkStore = "com/hypixel/hytale/server/core/universe/world/storage/ChunkStore";
78+
String EntityStore$UUIDSystem = "com/hypixel/hytale/server/core/universe/world/storage/EntityStore$UUIDSystem";
7879
String IndexedStorageChunkStorageProvider = "com/hypixel/hytale/server/core/universe/world/storage/provider/IndexedStorageChunkStorageProvider";
7980
String IndexedStorageChunkSaver = "com/hypixel/hytale/server/core/universe/world/storage/provider/IndexedStorageChunkStorageProvider$IndexedStorageChunkSaver";
8081
String WorldMapManager = "com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapManager";

patcher/src/main/java/com/fox2code/hypertale/patcher/patches/HypertalePatch.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ abstract class HypertalePatch implements Opcodes, HypertaleASMConstants {
3333
static final Void ALL_CLASSES = null;
3434
final String[] targets;
3535

36+
@SuppressWarnings("VoidUsed")
3637
HypertalePatch(Void ignored) {
3738
this.targets = null;
3839
this.checkAccess();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2026 Fox2Code
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.fox2code.hypertale.patcher.patches;
25+
26+
import com.fox2code.hypertale.utils.HytaleVersion;
27+
import org.objectweb.asm.tree.ClassNode;
28+
29+
abstract class HypertalePatchHotfix extends HypertalePatch {
30+
private final String forHypertaleVersion;
31+
32+
@SuppressWarnings("VoidUsed")
33+
HypertalePatchHotfix(String forHypertaleVersion, Void ignored) {
34+
super(ignored);
35+
this.forHypertaleVersion = forHypertaleVersion;
36+
}
37+
38+
HypertalePatchHotfix(String forHypertaleVersion, String target) {
39+
super(target);
40+
this.forHypertaleVersion = forHypertaleVersion;
41+
}
42+
43+
HypertalePatchHotfix(String forHypertaleVersion, String[] targets) {
44+
super(targets);
45+
this.forHypertaleVersion = forHypertaleVersion;
46+
}
47+
48+
HypertalePatchHotfix(String forHypertaleVersion, String target, String... targets) {
49+
super(target, targets);
50+
this.forHypertaleVersion = forHypertaleVersion;
51+
}
52+
53+
@Override
54+
public final ClassNode transform(ClassNode classNode) {
55+
if (HytaleVersion.HYTALE_VERSION.equals(this.forHypertaleVersion)) {
56+
return this.transformHotfix(classNode);
57+
}
58+
return classNode;
59+
}
60+
61+
public abstract ClassNode transformHotfix(ClassNode classNode);
62+
}

patcher/src/main/java/com/fox2code/hypertale/patcher/patches/HypertalePatches.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ public final class HypertalePatches {
3232
private static final ArrayList<HypertalePatch> noPatches = new ArrayList<>();
3333
private static final ArrayList<HypertalePatch> globalHypertalePatches = new ArrayList<>();
3434
private static final HashMap<String, ArrayList<HypertalePatch>> hypertaleClassPatches = new HashMap<>();
35+
private static final boolean loaded;
36+
3537
static void addPatch(HypertalePatch hypertalePatch) {
38+
if (loaded) {
39+
throw new IllegalStateException("Cannot add patch after HypertalePatches has been loaded");
40+
}
3641
if (hypertalePatch.targets == null) {
3742
globalHypertalePatches.add(hypertalePatch);
3843
} else {
@@ -45,6 +50,16 @@ static void addPatch(HypertalePatch hypertalePatch) {
4550
}
4651

4752
static {
53+
// Hypertale premium register its patches on its own.
54+
if (!Boolean.getBoolean("hypertale.premium")) {
55+
autoRegisterPatches();
56+
}
57+
HypertalePatchesPlus.registerPatches();
58+
loaded = true;
59+
}
60+
61+
// Callback to allow Hypertale plus to register default patches
62+
static void autoRegisterPatches() {
4863
addPatch(new PatchMat4f());
4964
addPatch(new PatchPluginClassLoader());
5065
addPatch(new PatchWorld());
@@ -57,11 +72,10 @@ static void addPatch(HypertalePatch hypertalePatch) {
5772
addPatch(new PatchPlugins());
5873
addPatch(new PatchExtraAuthenticationData());
5974
addPatch(new PatchHytaleLogFormatter());
60-
addPatch(new PatchUniverse());
6175
addPatch(new PatchInventory());
6276
addPatch(new PatchRedirectToOptimisedGetPlayers());
6377
addPatch(new PatchRedirectToOptimisedGetChunkIfInMemory());
64-
HypertalePatchesPlus.registerPatches();
78+
6579
}
6680

6781
public static ClassNode patchClassNode(ClassNode classNode) {

patcher/src/main/java/com/fox2code/hypertale/patcher/patches/HypertalePatchesPlus.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@
2727
* This class is overwritten by Hypertale Plus
2828
*/
2929
final class HypertalePatchesPlus {
30+
static boolean autoRegisterPatches() {
31+
return true;
32+
}
33+
3034
static void registerPatches() {}
3135
}

patcher/src/main/java/com/fox2code/hypertale/patcher/patches/PatchPluginClassLoader.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ public ClassNode transform(ClassNode classNode) {
5252
injection.add(new JumpInsnNode(Opcodes.IFEQ, skip));
5353
injection.add(new InsnNode(Opcodes.ICONST_1));
5454
injection.add(new InsnNode(Opcodes.IRETURN));
55+
injection.add(new VarInsnNode(Opcodes.ALOAD, varInsnNode.var));
56+
injection.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
57+
StackTraceElement, "getMethodName", "()L" + ASMString + ";", false));
58+
injection.add(new LdcInsnNode("hypertale"));
59+
injection.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
60+
ASMString, "startsWith", "(L" + ASMString + ";)Z", false));
61+
injection.add(new JumpInsnNode(Opcodes.IFEQ, skip));
62+
injection.add(new InsnNode(Opcodes.ICONST_1));
63+
injection.add(new InsnNode(Opcodes.IRETURN));
5564
injection.add(skip);
5665
isFromThirdPartyPlugin.instructions.insertBefore(ldcInsnNode, injection);
5766
break;

0 commit comments

Comments
 (0)