Skip to content

Commit 01a3ae0

Browse files
committed
Add minor Mat4f optimization and cleanup leftover debug logging!
1 parent 092e284 commit 01a3ae0

5 files changed

Lines changed: 85 additions & 6 deletions

File tree

launcher/src/main/java/com/fox2code/hypertale/loader/HypertalePlugin.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.fox2code.hypertale.utils.HypertalePlatform;
3232
import com.fox2code.hypertale.utils.HypertaleSystemInfo;
3333
import com.fox2code.hypertale.utils.SourceUtil;
34-
import com.hypixel.hytale.common.util.java.ManifestUtil;
3534
import com.hypixel.hytale.event.EventPriority;
3635
import com.hypixel.hytale.server.core.Constants;
3736
import com.hypixel.hytale.server.core.HytaleServer;
@@ -75,11 +74,6 @@ public HypertalePlugin(@NonNull JavaPluginInit init) {
7574
this.hypertale().setLoggerName(ANSI_MAGENTA + "Hypertale");
7675
}
7776
this.getLogger().atInfo().log("System information: " + HypertaleSystemInfo.SYSTEM);
78-
this.getLogger().atInfo().log("Target server: \"" + this.getManifest().getServerVersion() + "\"");
79-
this.getLogger().atInfo().log("Server: \"" + ManifestUtil.getVersion() + "\"");
80-
this.getLogger().atInfo().log("Equals: " + Objects.equals(
81-
ManifestUtil.getVersion(),
82-
this.getManifest().getServerVersion()));
8377
EarlyLogger.installLoggerFunction(this.getLogger().atInfo()::log);
8478
if (INVALID_INSTALLATION) {
8579
try {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public interface HypertaleASMConstants {
5151
String PluginManifest = "com/hypixel/hytale/common/plugin/PluginManifest";
5252
String HytaleLogger = "com/hypixel/hytale/logger/HytaleLogger";
5353
String HytaleLogFormatter = "com/hypixel/hytale/logger/backend/HytaleLogFormatter";
54+
String Mat4f = "com/hypixel/hytale/math/Mat4f";
5455
String ClassTransformer = "com/hypixel/hytale/plugin/early/ClassTransformer";
5556
String PacketIO = "com/hypixel/hytale/protocol/io/PacketIO";
5657
String IdentityTokenClaims = "com/hypixel/hytale/server/core/auth/JWTValidator$IdentityTokenClaims";

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ public LabelNode get(Object key) {
8080
map.get(tryCatchBlockNode.end), map.get(tryCatchBlockNode.handler), tryCatchBlockNode.type));
8181
}
8282
}
83+
if (methodNode.invisibleAnnotations != null) {
84+
methodNodeCopy.invisibleAnnotations = new ArrayList<>();
85+
for (AnnotationNode annotationNode : methodNode.invisibleAnnotations) {
86+
AnnotationNode annotationNodeCopy = new AnnotationNode(annotationNode.desc);
87+
annotationNode.accept(annotationNodeCopy);
88+
methodNodeCopy.invisibleAnnotations.add(annotationNodeCopy);
89+
}
90+
}
91+
if (methodNode.visibleAnnotations != null) {
92+
methodNodeCopy.visibleAnnotations = new ArrayList<>();
93+
for (AnnotationNode annotationNode : methodNode.visibleAnnotations) {
94+
AnnotationNode annotationNodeCopy = new AnnotationNode(annotationNode.desc);
95+
annotationNode.accept(annotationNodeCopy);
96+
methodNodeCopy.visibleAnnotations.add(annotationNodeCopy);
97+
}
98+
}
8399
return methodNodeCopy;
84100
}
85101

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static void addPatch(HypertalePatch hypertalePatch) {
4545
}
4646

4747
static {
48+
addPatch(new PatchMat4f());
4849
addPatch(new PatchPluginClassLoader());
4950
addPatch(new PatchWorld());
5051
addPatch(new PatchChunkStore());
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.patcher.TransformerUtils;
27+
import org.objectweb.asm.tree.*;
28+
29+
final class PatchMat4f extends HypertalePatch {
30+
PatchMat4f() {
31+
super(Mat4f);
32+
}
33+
34+
@Override
35+
public ClassNode transform(ClassNode classNode) {
36+
MethodNode identity = TransformerUtils.findMethod(classNode, "identity", "()L" + Mat4f + ";");
37+
if (identity == null || (identity.access & ACC_STATIC) == 0) return classNode;
38+
classNode.access |= TransformerUtils.ACC_COMPUTE_FRAMES;
39+
FieldNode fieldNode = new FieldNode(ACC_PRIVATE | ACC_STATIC | ACC_FINAL,
40+
"HYPERTALE_IDENTITY", "L" + Mat4f + ";", null, null);
41+
classNode.fields.addFirst(fieldNode);
42+
MethodNode init = TransformerUtils.findMethod(classNode, "<clinit>");
43+
if (init == null) {
44+
init = new MethodNode(ACC_STATIC, "<clinit>", "()V", null, null);
45+
init.instructions.add(new InsnNode(RETURN));
46+
classNode.methods.addFirst(init);
47+
}
48+
// Replace the identity method with the get field!
49+
MethodNode identityProxy = TransformerUtils.copyMethodNode(identity);
50+
identityProxy.instructions.clear();
51+
identityProxy.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name,
52+
"HYPERTALE_IDENTITY", "L" + Mat4f + ";"));
53+
identityProxy.instructions.add(new InsnNode(ARETURN));
54+
classNode.methods.add(identityProxy);
55+
identity.name = "identityOriginal";
56+
identity.access = ACC_PRIVATE | ACC_STATIC;
57+
58+
InsnList injection = new InsnList();
59+
injection.add(new MethodInsnNode(INVOKESTATIC, Mat4f, identity.name, "()L" + Mat4f + ";", false));
60+
injection.add(new FieldInsnNode(PUTSTATIC, classNode.name, "HYPERTALE_IDENTITY", "L" + Mat4f + ";"));
61+
injection.add(new InsnNode(RETURN));
62+
63+
TransformerUtils.insertToBeginningOfCode(init, injection);
64+
65+
return classNode;
66+
}
67+
}

0 commit comments

Comments
 (0)