Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

Commit 1498344

Browse files
authored
Angelica Support - Static -> Instanced (#14)
Static -> Instanced * Now significantly more thread safe
1 parent e8dab57 commit 1498344

20 files changed

+742
-236
lines changed

build.gradle

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1700844281
1+
//version: 1702141377
22
/*
33
DO NOT CHANGE THIS FILE!
44
Also, you may replace this file at any time if there is an update available.
@@ -28,27 +28,12 @@ import java.util.concurrent.TimeUnit
2828

2929
buildscript {
3030
repositories {
31-
mavenCentral()
32-
33-
maven {
34-
name 'forge'
35-
url 'https://maven.minecraftforge.net'
36-
}
3731
maven {
3832
// GTNH RetroFuturaGradle and ASM Fork
3933
name "GTNH Maven"
4034
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
4135
allowInsecureProtocol = true
4236
}
43-
maven {
44-
name 'sonatype'
45-
url 'https://oss.sonatype.org/content/repositories/snapshots/'
46-
}
47-
maven {
48-
name 'Scala CI dependencies'
49-
url 'https://repo1.maven.org/maven2/'
50-
}
51-
5237
mavenLocal()
5338
}
5439
}
@@ -69,7 +54,7 @@ plugins {
6954
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
7055
id 'com.modrinth.minotaur' version '2.+' apply false
7156
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
72-
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
57+
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.26'
7358
}
7459

7560
print("You might want to check out './gradlew :faq' if your build fails.\n")
@@ -628,7 +613,7 @@ repositories {
628613
}
629614
maven {
630615
name = "ic2"
631-
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
616+
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
632617
content {
633618
includeGroup "net.industrial-craft"
634619
}
@@ -687,6 +672,8 @@ configurations.all {
687672
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
688673
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
689674
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
675+
676+
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
690677
}
691678
}
692679

@@ -793,12 +780,12 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
793780
}
794781

795782
dependencies {
796-
def lwjgl3ifyVersion = '1.5.1'
783+
def lwjgl3ifyVersion = '1.5.7'
797784
if (modId != 'lwjgl3ify') {
798785
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
799786
}
800787
if (modId != 'hodgepodge') {
801-
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.17')
788+
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
802789
}
803790

804791
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
@@ -1310,7 +1297,7 @@ def addCurseForgeRelation(String type, String name) {
13101297

13111298
// Updating
13121299

1313-
def buildscriptGradleVersion = "8.2.1"
1300+
def buildscriptGradleVersion = "8.5"
13141301

13151302
tasks.named('wrapper', Wrapper).configure {
13161303
gradleVersion = buildscriptGradleVersion
@@ -1621,3 +1608,4 @@ if (file('addon.late.local.gradle.kts').exists()) {
16211608
} else if (file('addon.late.local.gradle').exists()) {
16221609
apply from: 'addon.late.local.gradle'
16231610
}
1611+

gradle.properties

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ forgeVersion = 10.13.4.1614
2121
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
2222
developmentEnvironmentUserName = Developer
2323

24+
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8.
25+
# See https://github.com/bsideup/jabel for details on how this works.
26+
enableModernJavaSyntax = true
27+
28+
# Enables injecting missing generics into the decompiled source code for a better coding experience
29+
# Turns most publically visible List, Map, etc. into proper List<Type>, Map<K, V> types
30+
enableGenericInjection = true
31+
32+
2433
# Define a source file of your project with:
2534
# public static final String VERSION = "GRADLETOKEN_VERSION";
2635
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
@@ -87,4 +96,3 @@ modrinthProjectId = codechickenlib-unofficial
8796
# and the name is the Modrinth project or version slug/id of the other mod.
8897

8998
# modrinthRelations =
90-
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package codechicken.lib.asm;
2+
3+
/***
4+
* This Class is derived from the ASM ClassReader
5+
* <p>
6+
* ASM: a very small and fast Java bytecode manipulation framework Copyright (c) 2000-2011 INRIA, France Telecom All
7+
* rights reserved.
8+
* <p>
9+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
10+
* following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of
11+
* conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation and/or other materials provided with the
13+
* distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse
14+
* or promote products derived from this software without specific prior written permission.
15+
* <p>
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
*/
24+
25+
import java.nio.charset.StandardCharsets;
26+
27+
import org.objectweb.asm.Opcodes;
28+
29+
/**
30+
* Using this class to search for a (single) String reference is > 40 times faster than parsing a class with a
31+
* ClassReader + ClassNode while using way less RAM
32+
*/
33+
public class ClassConstantPoolParser {
34+
35+
private static final int UTF8 = 1;
36+
private static final int INT = 3;
37+
private static final int FLOAT = 4;
38+
private static final int LONG = 5;
39+
private static final int DOUBLE = 6;
40+
private static final int FIELD = 9;
41+
private static final int METH = 10;
42+
private static final int IMETH = 11;
43+
private static final int NAME_TYPE = 12;
44+
private static final int HANDLE = 15;
45+
private static final int INDY = 18;
46+
47+
private final byte[][] BYTES_TO_SEARCH;
48+
49+
public ClassConstantPoolParser(String... strings) {
50+
BYTES_TO_SEARCH = new byte[strings.length][];
51+
for (int i = 0; i < BYTES_TO_SEARCH.length; i++) {
52+
BYTES_TO_SEARCH[i] = strings[i].getBytes(StandardCharsets.UTF_8);
53+
}
54+
}
55+
56+
/**
57+
* Returns true if the constant pool of the class represented by this byte array contains one of the Strings we are
58+
* looking for
59+
*/
60+
public boolean find(byte[] basicClass) {
61+
if (basicClass == null || basicClass.length == 0) {
62+
return false;
63+
}
64+
// checks the class version
65+
if (readShort(6, basicClass) > Opcodes.V1_8) {
66+
return false;
67+
}
68+
// parses the constant pool
69+
int n = readUnsignedShort(8, basicClass);
70+
int index = 10;
71+
for (int i = 1; i < n; ++i) {
72+
int size;
73+
switch (basicClass[index]) {
74+
case FIELD, METH, IMETH, INT, FLOAT, NAME_TYPE, INDY -> size = 5;
75+
case LONG, DOUBLE -> {
76+
size = 9;
77+
++i;
78+
}
79+
case UTF8 -> {
80+
final int strLen = readUnsignedShort(index + 1, basicClass);
81+
size = 3 + strLen;
82+
label: for (byte[] bytes : BYTES_TO_SEARCH) {
83+
if (strLen == bytes.length) {
84+
for (int j = index + 3; j < index + 3 + strLen; j++) {
85+
if (basicClass[j] != bytes[j - (index + 3)]) {
86+
break label;
87+
}
88+
}
89+
return true;
90+
}
91+
}
92+
}
93+
case HANDLE -> size = 4;
94+
default -> size = 3;
95+
}
96+
index += size;
97+
}
98+
return false;
99+
}
100+
101+
private static short readShort(final int index, byte[] basicClass) {
102+
return (short) (((basicClass[index] & 0xFF) << 8) | (basicClass[index + 1] & 0xFF));
103+
}
104+
105+
private static int readUnsignedShort(final int index, byte[] basicClass) {
106+
return ((basicClass[index] & 0xFF) << 8) | (basicClass[index + 1] & 0xFF);
107+
}
108+
109+
}

src/main/java/codechicken/lib/asm/ObfMapping.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class ObfMapping {
3636

3737
public static class ObfRemapper extends Remapper {
3838

39-
private HashMap<String, String> fields = new HashMap<String, String>();
40-
private HashMap<String, String> funcs = new HashMap<String, String>();
39+
private final HashMap<String, String> fields = new HashMap<>();
40+
private final HashMap<String, String> funcs = new HashMap<>();
4141

4242
public ObfRemapper() {
4343
try {
@@ -174,8 +174,8 @@ public static File[] parseConfDir(File confDir) {
174174
return new File[] { srgs, methods, fields };
175175
}
176176

177-
private HashMap<String, String> fields = new HashMap<String, String>();
178-
private HashMap<String, String> funcs = new HashMap<String, String>();
177+
private final HashMap<String, String> fields = new HashMap<>();
178+
private final HashMap<String, String> funcs = new HashMap<>();
179179

180180
public MCPRemapper() {
181181
File[] mappings = getConfFiles();

0 commit comments

Comments
 (0)