Skip to content

Commit 63011d8

Browse files
authored
Develop 1.21.1 beta 2 (Sinytra#1335)
2 parents 48e0ff0 + 0b2b43c commit 63011d8

File tree

10 files changed

+114
-51
lines changed

10 files changed

+114
-51
lines changed

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
with:
3737
distribution: 'microsoft'
3838
java-version: '21'
39-
- uses: gradle/wrapper-validation-action@v1
39+
- uses: gradle/actions/wrapper-validation@v3
4040
- name: Setup Gradle
4141
uses: gradle/actions/setup-gradle@v3
4242
with:
@@ -75,7 +75,7 @@ jobs:
7575
with:
7676
distribution: 'microsoft'
7777
java-version: '21'
78-
- uses: gradle/wrapper-validation-action@v1
78+
- uses: gradle/actions/wrapper-validation@v3
7979
- name: Setup Gradle
8080
uses: gradle/actions/setup-gradle@v3
8181
with:

build.gradle.kts

+14-14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ val versionAdapterDefinition: String by project
1919
val versionAdapterRuntime: String by project
2020
val versionMc: String by project
2121
val versionNeoForge: String by project
22+
val versionParchmentMc: String by project
2223
val versionParchment: String by project
2324
val versionForgeAutoRenamingTool: String by project
2425
val versionForgifiedFabricLoader: String by project
@@ -47,10 +48,7 @@ logger.lifecycle("Project version: $version")
4748
val mod: SourceSet by sourceSets.creating
4849
val test: SourceSet by sourceSets
4950

50-
val shade: Configuration by configurations.creating {
51-
isTransitive = false
52-
}
53-
val legacyClasspath: Configuration by configurations.creating { isTransitive = false }
51+
val shade: Configuration by configurations.creating
5452
val adapterData: Configuration by configurations.creating
5553

5654
java {
@@ -72,7 +70,7 @@ configurations {
7270
}
7371

7472
additionalRuntimeClasspath {
75-
extendsFrom(legacyClasspath)
73+
extendsFrom(shade)
7674
}
7775
}
7876

@@ -87,7 +85,7 @@ neoForge {
8785

8886
parchment {
8987
mappingsVersion = versionParchment
90-
minecraftVersion = versionMc
88+
minecraftVersion = versionParchmentMc
9189
}
9290

9391
runs {
@@ -134,10 +132,9 @@ repositories {
134132

135133
dependencies {
136134
shade(group = "org.sinytra", name = "forgified-fabric-loader", version = versionForgifiedFabricLoader)
137-
legacyClasspath(group = "org.sinytra", name = "forgified-fabric-loader", version = versionForgifiedFabricLoader, classifier = "full")
138-
legacyClasspath(shade(group = "net.fabricmc", name = "access-widener", version = versionAccessWidener))
139-
legacyClasspath(shade(group = "org.sinytra", name = "ForgeAutoRenamingTool", version = versionForgeAutoRenamingTool))
140-
legacyClasspath(shade(group = "org.sinytra.adapter", name = "definition", version = versionAdapterDefinition) { isTransitive = false })
135+
shade(group = "net.fabricmc", name = "access-widener", version = versionAccessWidener) { isTransitive = false }
136+
shade(group = "org.sinytra", name = "ForgeAutoRenamingTool", version = versionForgeAutoRenamingTool) { isTransitive = false }
137+
shade(group = "org.sinytra.adapter", name = "definition", version = versionAdapterDefinition) { isTransitive = false }
141138
adapterData(group = "org.sinytra.adapter", name = "adapter", version = versionAdapter)
142139

143140
jarJar(implementation(group = "org.sinytra.adapter", name = "runtime", version = versionAdapterRuntime))
@@ -148,6 +145,8 @@ dependencies {
148145
"modCompileOnly"(sourceSets.main.get().output)
149146

150147
additionalRuntimeClasspath(files(tasks.jar))
148+
149+
implementation("curse.maven:connector-extras-913445:5618470")
151150
}
152151

153152
val modJar: Jar by tasks.creating(Jar::class) {
@@ -160,10 +159,11 @@ localJarJar("modJarConfig", "org.sinytra:connector-mod", project.version.toStrin
160159
val depsJar: ShadowJar by tasks.creating(ShadowJar::class) {
161160
configurations = listOf(shade)
162161

163-
exclude("assets/fabricloader/**")
164-
exclude("META-INF/*.SF")
165-
exclude("META-INF/*.RSA")
166-
exclude("META-INF/maven/**")
162+
exclude(
163+
"assets/fabricloader/**",
164+
"META-INF/*.SF", "META-INF/*.RSA",
165+
"META-INF/maven/**", "META-INF/jars/**", "META-INF/jarjar/**"
166+
)
167167
exclude("META-INF/services/net.neoforged.neoforgespi.language.IModLanguageLoader")
168168
exclude("ui/**")
169169
exclude("*.json", "*.html", "*.version")

gradle.properties

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ org.gradle.caching=true
77
#org.gradle.configuration-cache=true
88

99
# Versions
10-
versionConnector=2.0.0-beta.1
11-
versionAdapter=1.13.1+1.21-20240719.094540
12-
versionAdapterDefinition=1.13.16+1.21
13-
versionAdapterRuntime=1.0.0+1.21
10+
versionConnector=2.0.0-beta.2
11+
versionAdapter=1.13.20+1.21.1-20240811.191740
12+
versionAdapterDefinition=1.13.21+1.21.1
13+
versionAdapterRuntime=1.0.0+1.21.1
1414

15-
versionMc=1.21
16-
versionNeoForge=21.0.160
17-
versionParchment=2024.06.23
15+
versionMc=1.21.1
16+
versionNeoForge=21.1.5
17+
versionParchmentMc=1.21
18+
versionParchment=2024.07.28
1819
versionForgeAutoRenamingTool=1.0.12
19-
versionForgifiedFabricLoader=2.5.29+0.16.0+1.21
20+
versionForgifiedFabricLoader=2.5.33+0.16.0+1.21.1
2021
versionAccessWidener=2.1.0
21-
versionForgifiedFabricApi=0.100.7+2.0.8+1.21
22+
versionForgifiedFabricApi=0.102.0+2.0.11+1.21.1
2223

2324
# Publishing
2425
curseForgeId=890127

src/main/java/org/sinytra/connector/ConnectorCoremods.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
import net.neoforged.neoforgespi.coremod.ICoreMod;
1111
import org.objectweb.asm.MethodVisitor;
1212
import org.objectweb.asm.Opcodes;
13+
import org.objectweb.asm.Type;
1314
import org.objectweb.asm.tree.ClassNode;
1415
import org.objectweb.asm.tree.FieldNode;
1516
import org.objectweb.asm.tree.InsnList;
1617
import org.objectweb.asm.tree.InsnNode;
18+
import org.objectweb.asm.tree.LocalVariableNode;
1719
import org.objectweb.asm.tree.MethodInsnNode;
1820
import org.objectweb.asm.tree.MethodNode;
1921
import org.objectweb.asm.tree.TypeInsnNode;
2022
import org.objectweb.asm.tree.VarInsnNode;
23+
import org.sinytra.adapter.patch.analysis.locals.LocalVariableLookup;
2124
import org.slf4j.Logger;
2225

2326
import java.util.List;
@@ -113,12 +116,29 @@ public Iterable<? extends ITransformer<?>> getTransformers() {
113116
}
114117
}
115118
);
119+
ITransformer<?> expandLocalVarScope = new BaseTransformer<>(
120+
TargetType.METHOD,
121+
ITransformer.Target.targetMethod("net.minecraft.world.entity.LivingEntity", "forceAddEffect", "(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)V"),
122+
input -> {
123+
LocalVariableLookup lvt = new LocalVariableLookup(input);
124+
LocalVariableNode mobEffect = lvt.getByTypedOrdinal(Type.getObjectType("net/minecraft/world/effect/MobEffectInstance"), 1).orElse(null);
125+
if (mobEffect != null) {
126+
mobEffect.start = lvt.getByIndex(0).start;
127+
input.instructions.insert(mobEffect.start, ASMAPI.listOf(
128+
new InsnNode(Opcodes.ACONST_NULL),
129+
new VarInsnNode(Opcodes.ASTORE, mobEffect.index)
130+
));
131+
LOGGER.debug("Expanded local variable scope for LivingEntity#forceAddEffect index {}", mobEffect.index);
132+
}
133+
}
134+
);
116135

117136
return ImmutableList.<ITransformer<?>>builder()
118137
.add(keyMappingFieldTypeTransform, creativeModeTabConstructorTransform)
119138
.addAll(addedFields)
120139
.addAll(getFabricASMTransformers())
121140
.add(missingOrderingCall)
141+
.add(expandLocalVarScope)
122142
.build();
123143
}
124144

@@ -128,7 +148,7 @@ private static ITransformer<?> addFieldToClass(String cls, String name, String d
128148
ITransformer.Target.targetClass(cls),
129149
input -> {
130150
input.fields.add(new FieldNode(access, name, desc, null, null));
131-
151+
132152
LOGGER.debug("Added field {} to class {}", name, cls);
133153
}
134154
);

src/main/java/org/sinytra/connector/transformer/MixinPatches.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ public static List<Patch> getPatches() {
108108
return Patch.Result.APPLY;
109109
})
110110
.build(),
111+
// NeoForge moves this behaviour out completely with no viable replacement, so we disable it for now
112+
Patch.builder()
113+
.targetClass("net/minecraft/world/entity/animal/SnowGolem", "net/minecraft/world/entity/animal/Sheep", "net/minecraft/world/entity/animal/MushroomCow")
114+
.targetMethod("mobInteract")
115+
.targetInjectionPoint("Lnet/minecraft/world/item/ItemStack;is(Lnet/minecraft/world/item/Item;)Z")
116+
.disable()
117+
.build(),
111118
// ======= Rendering patches
112119
Patch.builder()
113120
.targetClass("net/minecraft/client/renderer/ShaderInstance")
@@ -151,13 +158,6 @@ public static List<Patch> getPatches() {
151158
})
152159
.modifyInjectionPoint("Lnet/minecraft/client/renderer/entity/layers/ElytraLayer;shouldRender(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/LivingEntity;)Z")
153160
.build(),
154-
// ======= GUI Rendering patches TODO Can adapter automate these?
155-
Patch.builder()
156-
.targetClass("net/minecraft/client/gui/Gui")
157-
.targetMethod("renderPlayerHealth")
158-
.targetInjectionPoint("Lnet/minecraft/client/gui/Gui;renderHearts(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/entity/player/Player;IIIIFIIIZ)V")
159-
.modifyTarget("renderHealthLevel")
160-
.build(),
161161
// ======= TODO Handle in adapter
162162
Patch.builder()
163163
.targetClass("net/minecraft/world/entity/vehicle/Boat")

src/main/java/org/sinytra/connector/transformer/OptimizedRenamingTransformer.java

+16-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.objectweb.asm.tree.LdcInsnNode;
2525
import org.objectweb.asm.tree.MethodInsnNode;
2626
import org.objectweb.asm.tree.MethodNode;
27+
import org.objectweb.asm.tree.VarInsnNode;
28+
import org.sinytra.adapter.patch.analysis.MethodCallAnalyzer;
2729
import org.sinytra.adapter.patch.analysis.selector.AnnotationHandle;
2830
import org.sinytra.adapter.patch.analysis.selector.AnnotationValueHandle;
2931
import org.sinytra.adapter.patch.util.MethodQualifier;
@@ -105,20 +107,26 @@ protected void postProcess(ClassNode node) {
105107
}
106108

107109
private void avoidAmbigousMappingRecursion(ClassNode classNode, MethodNode method) {
108-
if (isOverridenMethod(classNode, method)) {
110+
if (isAmbigousOverridenMethod(classNode, method)) {
109111
for (AbstractInsnNode insn : method.instructions) {
110-
if (insn instanceof MethodInsnNode minsn && minsn.owner.equals(classNode.name) && minsn.name.equals(method.name) && minsn.desc.equals(method.desc)) {
111-
method.instructions.set(minsn, new MethodInsnNode(Opcodes.INVOKESPECIAL, classNode.superName, minsn.name, minsn.desc, minsn.itf));
112+
if (insn instanceof MethodInsnNode minsn && minsn.getOpcode() == Opcodes.INVOKEVIRTUAL && minsn.owner.equals(classNode.name) && minsn.name.equals(method.name) && minsn.desc.equals(method.desc)) {
113+
List<AbstractInsnNode> insns = MethodCallAnalyzer.findMethodCallParamInsns(method, minsn);
114+
if (!insns.isEmpty() && insns.getFirst() instanceof VarInsnNode varInsn && varInsn.var == 0) {
115+
method.instructions.set(minsn, new MethodInsnNode(Opcodes.INVOKESPECIAL, classNode.superName, minsn.name, minsn.desc, minsn.itf));
116+
}
112117
}
113118
}
114119
}
115120
}
116121

117-
private boolean isOverridenMethod(ClassNode classNode, MethodNode method) {
118-
return classNode.superName != null && ((MixinAwareEnhancedRemapper) this.remapper).getUpstreamProvider().getClass(classNode.superName)
119-
.flatMap(m -> m.getMethod(method.name, method.desc))
120-
.filter(m -> (m.getAccess() & (ACC_PRIVATE | ACC_STATIC)) == 0)
121-
.isPresent();
122+
private boolean isAmbigousOverridenMethod(ClassNode classNode, MethodNode method) {
123+
return classNode.superName != null && this.remapper.getClass(classNode.name)
124+
.map(c -> c.getMethods().stream()
125+
.flatMap(Optional::stream)
126+
.filter(m -> !m.getName().equals(m.getMapped()) && m.getMapped().equals(method.name) && method.desc.equals(this.remapper.mapMethodDesc(m.getDescriptor()))
127+
&& (m.getAccess() & (ACC_PRIVATE | ACC_STATIC)) == 0)
128+
.count() > 1)
129+
.orElse(false);
122130
}
123131

124132
private void processMixinAnnotation(AnnotationNode annotation, PostProcessRemapper postProcessRemapper) {

src/mod/java/org/sinytra/connector/mod/compat/LazyEntityAttributes.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class LazyEntityAttributes {
2929

3030
public static void inject() {
3131
for (Holder<Attribute> holder : ATTRIBUTES) {
32-
Holder<Attribute> lazyAttribute = PLACEHOLDERS.computeIfAbsent(holder, s -> Holder.direct(new PlaceholderAttribute()));
32+
Holder<Attribute> lazyAttribute = replaceAttribute(holder);
3333
try {
3434
DEFERRED_HOLDER_SET_VALUE.invoke(holder, lazyAttribute);
3535
} catch (Throwable e) {
@@ -48,6 +48,10 @@ public static void release() {
4848
}
4949
}
5050

51+
public static Holder<Attribute> replaceAttribute(Holder<Attribute> original) {
52+
return PLACEHOLDERS.computeIfAbsent(original, s -> Holder.direct(new PlaceholderAttribute()));
53+
}
54+
5155
public static void initializeLazyAttributes(EntityAttributeModificationEvent event) {
5256
updateAttributeSuppliers(ObfuscationReflectionHelper.getPrivateValue(DefaultAttributes.class, null, "SUPPLIERS"));
5357
updateAttributeSuppliers(CommonHooks.getAttributesView());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.sinytra.connector.mod.mixin;
2+
3+
import net.minecraft.core.Holder;
4+
import net.minecraft.world.entity.ai.attributes.Attribute;
5+
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
6+
import org.sinytra.connector.mod.ConnectorLoader;
7+
import org.sinytra.connector.mod.compat.LazyEntityAttributes;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
11+
12+
@Mixin(AttributeSupplier.Builder.class)
13+
public abstract class AttributeSupplierBuilderMixin {
14+
15+
// Mitigates https://github.com/Sinytra/Connector/issues/1298
16+
@ModifyVariable(method = "create", at = @At("HEAD"), argsOnly = true)
17+
private Holder<Attribute> onCreate(Holder<Attribute> original) {
18+
if (ConnectorLoader.isLoading()) {
19+
try {
20+
original.value();
21+
} catch (NullPointerException n) {
22+
// Likely a deferred holder that has not been initialized yet
23+
return LazyEntityAttributes.replaceAttribute(original);
24+
}
25+
}
26+
return original;
27+
}
28+
}

src/mod/resources/META-INF/neoforge.mods.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ logoFile="logo.png"
1111
authors="Su5eD"
1212
displayURL="https://github.com/Sinytra/Connector"
1313
description='''
14-
Connector is a translation/compatibility layer that allows running Fabric mods on MinecraftForge.
14+
Connector is a translation/compatibility layer that allows running Fabric mods on NeoForge.
1515
Its goal is to bring the two platforms closer together, saving developers time and effort maintaining their mods for
1616
multiple platforms at once, as well as allowing players to play all their favourite mods in one modpack.
1717
'''
1818
displayTest = 'IGNORE_ALL_VERSION' # Connector is optional for both sides
1919
[[mixins]]
2020
config="connector.mixins.json"
21-
[[dependencies.connectormod]]
21+
[[dependencies.connector]]
2222
modId="neoforge"
23-
mandatory=true
23+
type="required"
2424
versionRange="*"
2525
ordering="NONE"
2626
side="BOTH"
27-
[[dependencies.connectormod]]
27+
[[dependencies.connector]]
2828
modId="minecraft"
29-
mandatory=true
29+
type="required"
3030
versionRange="[1.21,1.22)"
3131
ordering="NONE"
3232
side="BOTH"

src/mod/resources/connector.mixins.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"compatibilityLevel": "JAVA_17",
66
"plugin": "org.sinytra.connector.mod.ConnectorBootstrap",
77
"mixins": [
8+
"AttributeSupplierBuilderMixin",
9+
"ChunkGeneratorMixin",
810
"CommonHooksMixin",
911
"PlayerListMixin",
10-
"ChunkGeneratorMixin",
1112
"boot.DatagenModLoaderMixin",
1213
"item.IItemExtensionMixin",
1314
"item.ItemStackMixin",
@@ -17,21 +18,22 @@
1718
"recipebook.RecipeBookManagerMixin",
1819
"registries.DataPackRegistriesHooksAccessor",
1920
"registries.MappedRegistryAccessor",
21+
"registries.NeoForgeRegistriesSetupAccessor",
2022
"registries.BuiltInRegistriesMixin",
2123
"registries.EntityDataSerializersMixin",
22-
"registries.NeoForgeRegistriesSetupAccessor",
24+
"registries.ItemBlockRenderTypesMixin",
2325
"registries.NeoForgeRegistriesSetupMixin",
2426
"registries.NetworkRegistryMixin",
2527
"registries.PoiTypesMixin",
2628
"registries.RegistryDataLoaderMixin"
2729
],
2830
"client": [
2931
"boot.MinecraftMixin",
32+
"client.BlockColorsMixin",
3033
"client.ForgeHooksClientMixin",
34+
"client.ItemColorsMixin",
3135
"client.ItemOverridesMixin",
3236
"client.KeyMappingMixin",
33-
"client.BlockColorsMixin",
34-
"client.ItemColorsMixin",
3537
"client.ParticleEngineMixin"
3638
],
3739
"server": [

0 commit comments

Comments
 (0)