mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-29 16:47:56 +00:00
Merge branch 'mc-1.20.x' into mc-1.21.x
Oh, I'm sure I missed something here. This was a nasty merge, has the docs have changed so much in each version.
This commit is contained in:
@@ -106,8 +106,6 @@ dependencies {
|
||||
testFixturesImplementation(testFixtures(project(":core")))
|
||||
}
|
||||
|
||||
sourceSets.main { resources.srcDir("src/generated/resources") }
|
||||
|
||||
loom {
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/computercraft.accesswidener"))
|
||||
mixin.useLegacyMixinAp = false
|
||||
@@ -126,6 +124,10 @@ loom {
|
||||
sourceSet(sourceSets.testMod.get())
|
||||
sourceSet(project(":common").sourceSets.testMod.get())
|
||||
}
|
||||
|
||||
register("examplemod") {
|
||||
sourceSet(sourceSets.examples.get())
|
||||
}
|
||||
}
|
||||
|
||||
runs {
|
||||
@@ -143,19 +145,24 @@ loom {
|
||||
runDir("run/server")
|
||||
}
|
||||
|
||||
register("data") {
|
||||
configName = "Datagen"
|
||||
fun RunConfigSettings.configureForData(sourceSet: SourceSet) {
|
||||
client()
|
||||
|
||||
source(sourceSets.datagen.get())
|
||||
|
||||
runDir("run/dataGen")
|
||||
runDir("run/run${name.capitalise()}")
|
||||
property("fabric-api.datagen")
|
||||
property("fabric-api.datagen.output-dir", layout.buildDirectory.dir("generatedResources").getAbsolutePath())
|
||||
property(
|
||||
"fabric-api.datagen.output-dir",
|
||||
layout.buildDirectory.dir(sourceSet.getTaskName("generateResources", null)).getAbsolutePath(),
|
||||
)
|
||||
property("fabric-api.datagen.strict-validation")
|
||||
}
|
||||
|
||||
fun configureForGameTest(config: RunConfigSettings) = config.run {
|
||||
register("data") {
|
||||
configName = "Datagen"
|
||||
configureForData(sourceSets.main.get())
|
||||
source(sourceSets.datagen.get())
|
||||
}
|
||||
|
||||
fun RunConfigSettings.configureForGameTest() {
|
||||
source(sourceSets.testMod.get())
|
||||
|
||||
val testSources = project(":common").file("src/testMod/resources/data/cctest").absolutePath
|
||||
@@ -170,7 +177,7 @@ loom {
|
||||
val testClient by registering {
|
||||
configName = "Test Client"
|
||||
client()
|
||||
configureForGameTest(this)
|
||||
configureForGameTest()
|
||||
|
||||
runDir("run/testClient")
|
||||
property("cctest.tags", "client,common")
|
||||
@@ -179,16 +186,27 @@ loom {
|
||||
register("gametest") {
|
||||
configName = "Game Test"
|
||||
server()
|
||||
configureForGameTest(this)
|
||||
configureForGameTest()
|
||||
|
||||
property("fabric-api.gametest")
|
||||
property(
|
||||
"fabric-api.gametest.report-file",
|
||||
layout.buildDirectory.dir("test-results/runGametest.xml")
|
||||
.getAbsolutePath(),
|
||||
layout.buildDirectory.dir("test-results/runGametest.xml").getAbsolutePath(),
|
||||
)
|
||||
runDir("run/gametest")
|
||||
}
|
||||
|
||||
register("exampleClient") {
|
||||
client()
|
||||
configName = "Example Mod Client"
|
||||
source(sourceSets.examples.get())
|
||||
}
|
||||
|
||||
register("exampleData") {
|
||||
configName = "Example Mod Datagen"
|
||||
configureForData(sourceSets.examples.get())
|
||||
source(sourceSets.examples.get())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package com.example.examplemod;
|
||||
|
||||
import com.example.examplemod.peripheral.BrewingStandPeripheral;
|
||||
import dan200.computercraft.api.peripheral.PeripheralLookup;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.upgrades.UpgradeType;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
/**
|
||||
* The main entry point for our example mod.
|
||||
*/
|
||||
public class FabricExampleMod implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// @start region=turtle_upgrades
|
||||
@SuppressWarnings("unchecked")
|
||||
var turtleUpgradeSerialisers = (Registry<UpgradeType<? extends ITurtleUpgrade>>) BuiltInRegistries.REGISTRY.get(ITurtleUpgrade.typeRegistry().location());
|
||||
Registry.register(turtleUpgradeSerialisers, ResourceLocation.fromNamespaceAndPath(ExampleMod.MOD_ID, "example_turtle_upgrade"), ExampleMod.EXAMPLE_TURTLE_UPGRADE);
|
||||
// @end region=turtle_upgrades
|
||||
|
||||
ExampleMod.registerComputerCraft();
|
||||
|
||||
// @start region=peripherals
|
||||
PeripheralLookup.get().registerForBlockEntity((f, s) -> new BrewingStandPeripheral(f), BlockEntityType.BREWING_STAND);
|
||||
// @end region=peripherals
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.example.examplemod;
|
||||
|
||||
import dan200.computercraft.api.client.FabricComputerCraftAPIClient;
|
||||
import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
public class FabricExampleModClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// @start region=turtle_modellers
|
||||
FabricComputerCraftAPIClient.registerTurtleUpgradeModeller(ExampleMod.EXAMPLE_TURTLE_UPGRADE, TurtleUpgradeModeller.flatItem());
|
||||
// @end region=turtle_modellers
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.example.examplemod;
|
||||
|
||||
import com.example.examplemod.data.TurtleUpgradeProvider;
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
|
||||
import net.fabricmc.fabric.api.event.registry.DynamicRegistries;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Data generators for our Fabric example mod.
|
||||
*/
|
||||
public class FabricExampleModDataGenerator implements DataGeneratorEntrypoint {
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator generator) {
|
||||
var pack = generator.createPack();
|
||||
addTurtleUpgrades(pack, generator.getRegistries());
|
||||
}
|
||||
|
||||
// @start region=turtle_upgrades
|
||||
private static void addTurtleUpgrades(FabricDataGenerator.Pack pack, CompletableFuture<HolderLookup.Provider> registries) {
|
||||
var fullRegistryPatch = TurtleUpgradeProvider.makeUpgradeRegistry(registries);
|
||||
pack.addProvider((FabricDataOutput output) -> new AutomaticDynamicRegistryProvider(output, fullRegistryPatch));
|
||||
}
|
||||
|
||||
/**
|
||||
* A subclass of {@link FabricDynamicRegistryProvider} that writes all new entries.
|
||||
*/
|
||||
private static class AutomaticDynamicRegistryProvider extends FabricDynamicRegistryProvider {
|
||||
AutomaticDynamicRegistryProvider(FabricDataOutput output, CompletableFuture<RegistrySetBuilder.PatchedRegistries> registries) {
|
||||
super(output, registries.thenApply(RegistrySetBuilder.PatchedRegistries::patches));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HolderLookup.Provider registries, Entries entries) {
|
||||
for (var r : DynamicRegistries.getDynamicRegistries()) entries.addAll(registries.lookupOrThrow(r.key()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Registries";
|
||||
}
|
||||
}
|
||||
// @end region=turtle_upgrades
|
||||
}
|
16
projects/fabric/src/examples/resources/fabric.mod.json
Normal file
16
projects/fabric/src/examples/resources/fabric.mod.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "examplemod",
|
||||
"version": "1.0.0",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"com.example.examplemod.FabricExampleMod"
|
||||
],
|
||||
"fabric-datagen": [
|
||||
"com.example.examplemod.FabricExampleModDataGenerator"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
"computercraft": "*"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user