1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-14 05:44:52 +00:00

Actually update NeoForge to 1.20.5

NF now loads mods from neoforge.mods.toml rather than mods.toml, so CC
wasn't actually being loaded. Tests all passed, because they didn't get
run in the first place!
This commit is contained in:
Jonathan Coates 2024-04-26 17:57:20 +01:00
parent 01407544c9
commit 188806e8b0
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
17 changed files with 123 additions and 76 deletions

View File

@ -37,6 +37,7 @@ Files:
projects/fabric/src/testMod/resources/computercraft-gametest.fabric.mixins.json
projects/fabric/src/testMod/resources/fabric.mod.json
projects/forge/src/client/resources/computercraft-client.forge.mixins.json
projects/forge/src/main/resources/computercraft.forge.mixins.json
projects/web/src/frontend/mount/.settings
projects/web/src/frontend/mount/example.nfp
projects/web/src/frontend/mount/example.nft

View File

@ -6,7 +6,7 @@
# Minecraft
# MC version is specified in gradle.properties, as we need that in settings.gradle.
# Remember to update corresponding versions in fabric.mod.json/mods.toml
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
fabric-api = "0.97.6+1.20.5"
fabric-loader = "0.15.10"
neoForge = "20.5.0-beta"

View File

@ -1,57 +0,0 @@
// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.mixin;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.mojang.datafixers.DSL;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.datafixers.types.templates.TypeTemplate;
import com.mojang.datafixers.util.Pair;
import dan200.computercraft.impl.UpgradeManager;
import dan200.computercraft.shared.ModRegistry.DataComponents;
import net.minecraft.util.datafix.fixes.References;
import net.minecraft.util.datafix.schemas.V3818_3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import java.util.Arrays;
import java.util.stream.Stream;
/**
* Add our custom data components to the datafixer system.
*
* @see UpgradeManager#codec()
* @see DataComponents#POCKET_UPGRADE
* @see DataComponents#LEFT_TURTLE_UPGRADE
* @see DataComponents#RIGHT_TURTLE_UPGRADE
* @see ItemStackComponentizationFixMixin
*/
@Mixin(V3818_3.class)
class V3818_3Mixin {
@ModifyReturnValue(
method = "method_57277",
at = @At("TAIL")
)
@SuppressWarnings("UnusedMethod")
private static TypeTemplate addExtraTypes(TypeTemplate type, Schema schema) {
// Create a codec for UpgradeData
var upgradeData = DSL.optionalFields("components", References.DATA_COMPONENTS.in(schema));
return extraOptionalFields(type,
Pair.of("computercraft:pocket_upgrade", upgradeData),
Pair.of("computercraft:left_turtle_upgrade", upgradeData),
Pair.of("computercraft:right_turtle_upgrade", upgradeData)
);
}
@SafeVarargs
@SuppressWarnings("varargs")
private static TypeTemplate extraOptionalFields(TypeTemplate base, Pair<String, TypeTemplate>... fields) {
return DSL.and(Stream.concat(
Arrays.stream(fields).map(entry -> DSL.optional(DSL.field(entry.getFirst(), entry.getSecond()))),
Stream.of(base)
).toList());
}
}

View File

@ -7,14 +7,19 @@ package dan200.computercraft.shared.util;
import com.mojang.datafixers.DSL;
import com.mojang.datafixers.Typed;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.datafixers.types.templates.TypeTemplate;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.Dynamic;
import com.mojang.serialization.OptionalDynamic;
import dan200.computercraft.api.upgrades.UpgradeData;
import dan200.computercraft.impl.UpgradeManager;
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.media.items.PrintoutData;
import net.minecraft.util.datafix.fixes.ItemStackComponentizationFix;
import net.minecraft.util.datafix.fixes.References;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
@ -178,4 +183,35 @@ public class ComponentizationFixers {
return newUpgrade;
}
/**
* Add our custom data components to the datafixer system.
*
* @param type The existing component type definition.
* @param schema The current schema.
* @return The new component type definition.
* @see UpgradeManager#codec()
* @see ModRegistry.DataComponents#POCKET_UPGRADE
* @see ModRegistry.DataComponents#LEFT_TURTLE_UPGRADE
* @see ModRegistry.DataComponents#RIGHT_TURTLE_UPGRADE
*/
public static TypeTemplate addExtraTypes(TypeTemplate type, Schema schema) {
// Create a codec for UpgradeData
var upgradeData = DSL.optionalFields("components", References.DATA_COMPONENTS.in(schema));
return extraOptionalFields(type,
Pair.of("computercraft:pocket_upgrade", upgradeData),
Pair.of("computercraft:left_turtle_upgrade", upgradeData),
Pair.of("computercraft:right_turtle_upgrade", upgradeData)
);
}
@SafeVarargs
@SuppressWarnings("varargs")
private static TypeTemplate extraOptionalFields(TypeTemplate base, Pair<String, TypeTemplate>... fields) {
return DSL.and(Stream.concat(
Arrays.stream(fields).map(entry -> DSL.optional(DSL.field(entry.getFirst(), entry.getSecond()))),
Stream.of(base)
).toList());
}
}

View File

@ -2,14 +2,12 @@
"required": true,
"package": "dan200.computercraft.mixin",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"injectors": {
"defaultRequire": 1
},
"mixins": [
"V1460Mixin",
"V3818_3Mixin",
"ItemStackComponentizationFixMixin"
],
"refmap": "computercraft.refmap.json"
"ItemStackComponentizationFixMixin",
"V1460Mixin"
]
}

View File

@ -2,7 +2,7 @@
"required": true,
"package": "dan200.computercraft.mixin.gametest",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"injectors": {
"defaultRequire": 1
},

View File

@ -2,7 +2,7 @@
"required": true,
"package": "dan200.computercraft.mixin.client",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"injectors": {
"defaultRequire": 1
},

View File

@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.mixin;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.datafixers.types.templates.TypeTemplate;
import dan200.computercraft.shared.util.ComponentizationFixers;
import net.minecraft.util.datafix.schemas.V3818_3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
/**
* Add our custom data components to the datafixer system.
* <p>
* This mixin is identical between Fabric and NeoForge aside from using a different method name.
*/
@Mixin(V3818_3.class)
class V3818_3Mixin {
@ModifyReturnValue(method = "method_57277", at = @At("TAIL"))
@SuppressWarnings("UnusedMethod")
private static TypeTemplate addExtraTypes(TypeTemplate type, Schema schema) {
return ComponentizationFixers.addExtraTypes(type, schema);
}
}

View File

@ -169,12 +169,12 @@ public class PlatformHelperImpl implements PlatformHelper {
public RecipeIngredients getRecipeIngredients() {
return new RecipeIngredients(
Ingredient.of(ConventionalItemTags.REDSTONE_DUSTS),
Ingredient.of(Items.STRING),
Ingredient.of(ConventionalItemTags.STRINGS),
Ingredient.of(Items.LEATHER),
Ingredient.of(Items.STONE),
Ingredient.of(ConventionalItemTags.STONES),
Ingredient.of(ConventionalItemTags.GLASS_PANES),
Ingredient.of(ConventionalItemTags.GOLD_INGOTS),
Ingredient.of(Items.GOLD_BLOCK),
Ingredient.of(ConventionalItemTags.STORAGE_BLOCKS_GOLD),
Ingredient.of(ConventionalItemTags.IRON_INGOTS),
Ingredient.of(ConventionalItemTags.DYES),
Ingredient.of(Items.ENDER_PEARL),

View File

@ -2,7 +2,7 @@
"required": true,
"package": "dan200.computercraft.mixin",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"injectors": {
"defaultRequire": 1
},
@ -15,6 +15,7 @@
"PlayerChunkSenderMixin",
"ServerLevelMixin",
"TagEntryAccessor",
"TagsProviderMixin"
"TagsProviderMixin",
"V3818_3Mixin"
]
}

View File

@ -155,7 +155,7 @@ tasks.processResources {
inputs.property("modVersion", modVersion)
inputs.property("neoVersion", libs.versions.neoForge.get())
filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand(mapOf("neoVersion" to libs.versions.neoForge.get(), "file" to mapOf("jarVersion" to modVersion)))
}
}

View File

@ -2,13 +2,12 @@
"required": true,
"package": "dan200.computercraft.mixin.client",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"injectors": {
"defaultRequire": 1
},
"client": [
"BlockRenderDispatcherMixin",
"ClientPacketListenerMixin"
],
"refmap": "client-computercraft.refmap.json"
]
}

View File

@ -55,7 +55,7 @@ public class Generators {
@Override
public <T extends DataProvider> T add(BiFunction<PackOutput, CompletableFuture<HolderLookup.Provider>, T> factory) {
return generator.addProvider(p -> factory.apply(p, registries));
return generator.addProvider(p -> new PrettyDataProvider<>(factory.apply(p, registries))).provider();
}
@Override

View File

@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.mixin;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.datafixers.types.templates.TypeTemplate;
import dan200.computercraft.shared.util.ComponentizationFixers;
import net.minecraft.util.datafix.schemas.V3818_3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
/**
* Add our custom data components to the datafixer system.
* <p>
* This mixin is identical between Fabric and NeoForge aside from using a different method name.
*/
@Mixin(V3818_3.class)
class V3818_3Mixin {
@ModifyReturnValue(method = "lambda$registerTypes$0", at = @At("TAIL"))
@SuppressWarnings("UnusedMethod")
private static TypeTemplate addExtraTypes(TypeTemplate type, Schema schema) {
return ComponentizationFixers.addExtraTypes(type, schema);
}
}

View File

@ -33,5 +33,8 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
[[mixins]]
config = "computercraft.mixins.json"
[[mixins]]
config = "computercraft.forge.mixins.json"
[[mixins]]
config = "computercraft-client.forge.mixins.json"

View File

@ -0,0 +1,12 @@
{
"required": true,
"package": "dan200.computercraft.mixin",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_21",
"injectors": {
"defaultRequire": 1
},
"mixins": [
"V3818_3Mixin"
]
}