Skip to content

Commit

Permalink
Update to 1.21.1, runtime error due to architectury/architectury-api#579
Browse files Browse the repository at this point in the history


Signed-off-by: 秋雨落 <[email protected]>
  • Loading branch information
qyl27 committed Dec 19, 2024
1 parent da9498c commit 3e9e72d
Show file tree
Hide file tree
Showing 115 changed files with 1,318 additions and 1,548 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id 'java'
id 'architectury-plugin' version "${architect_plugin_version}"
id 'dev.architectury.loom' version "${architectury_loom_version}"
id 'com.gradleup.shadow' version "${shadow_plugin_version}" apply false
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ loom {
vmArg "-Dfabric-api.datagen.output-dir=${file("../src/main/generated")}"
vmArg '-Dfabric-api.datagen.modid=catsplus'

runDir 'build/datagen'
runDir 'run/datagen'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package cuteneko.catsplus.fabric;

import cuteneko.catsplus.fabric.data.CatPlayerFabric;
import cuteneko.catsplus.fabric.data.GeniusCatFabric;
import cuteneko.catsplus.data.ICatPlayer;
import cuteneko.catsplus.data.entity.GeniusCat;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.player.PlayerEntity;
import cuteneko.catsplus.fabric.mixins.impl.ICatEntityMixin;
import net.minecraft.world.entity.animal.Cat;

public class CatsPlusDataImpl {
public static ICatPlayer getCatPlayer(PlayerEntity player) {
return new CatPlayerFabric(player);
}

public static GeniusCat getGeniusCat(CatEntity cat) {
return new GeniusCatFabric(cat);
public static GeniusCat getGeniusCat(Cat cat) {
return ((ICatEntityMixin) cat).catsplus$getGeniusCat();
}
}
24 changes: 2 additions & 22 deletions fabric/src/main/java/cuteneko/catsplus/fabric/CatsPlusFabric.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
package cuteneko.catsplus.fabric;

import cuteneko.catsplus.CatsPlus;
import cuteneko.catsplus.item.ModItems;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.item.DyeableItem;

public class CatsPlusFabric implements ModInitializer, ClientModInitializer {
private final CatsPlus mod;

public CatsPlusFabric() {
mod = new CatsPlus();
}

public class CatsPlusFabric implements ModInitializer {
@Override
public void onInitialize() {
mod.init();
}

@Override
public void onInitializeClient() {
mod.initClient();

ColorProviderRegistry.ITEM.register(
(stack, tintIndex) -> tintIndex == 0 ? ((DyeableItem) stack.getItem()).getColor(stack) : -1,
ModItems.CAT_BAG.get()
);
CatsPlus.init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cuteneko.catsplus.fabric.client;

import cuteneko.catsplus.client.CatsPlusClient;
import cuteneko.catsplus.item.ModItems;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.core.component.DataComponents;

public class CatsPlusFabricClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
CatsPlusClient.initClient();

ColorProviderRegistry.ITEM.register((stack, tintIndex) -> {
if (tintIndex == 0) {
var color = stack.get(DataComponents.DYED_COLOR);
if (color != null) {
return color.rgb();
}
}
return -1;
}, ModItems.CAT_BAG.get());
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cuteneko.catsplus.fabric.data.gen;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.core.HolderLookup;

import java.util.concurrent.CompletableFuture;

public class ModBlockTagProvider extends FabricTagProvider.BlockTagProvider {

public ModBlockTagProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> registriesFuture) {
super(output, registriesFuture);
}

@Override
protected void addTags(HolderLookup.Provider provider) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public void onInitializeDataGenerator(FabricDataGenerator generator) {
pack.addProvider(ModItemModelProvider::new);

pack.addProvider(ModRecipeProvider::new);
pack.addProvider(ModItemTagProvider::new);

var blockTags = pack.addProvider(ModBlockTagProvider::new);
pack.addProvider((output, registry) -> new ModItemTagProvider(output, registry, blockTags));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
import cuteneko.catsplus.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.Models;
import net.minecraft.data.models.BlockModelGenerators;
import net.minecraft.data.models.ItemModelGenerators;
import net.minecraft.data.models.model.ModelTemplates;

public class ModItemModelProvider extends FabricModelProvider {

public ModItemModelProvider(FabricDataOutput output) {
super(output);
}

@Override
public void generateBlockStateModels(BlockStateModelGenerator generator) {
public void generateBlockStateModels(BlockModelGenerators generator) {

}

@Override
public void generateItemModels(ItemModelGenerator generator) {
generator.register(ModItems.TOTEMEOW.get(), Models.GENERATED);
public void generateItemModels(ItemModelGenerators generator) {
generator.generateFlatItem(ModItems.TOTEMEOW.get(), ModelTemplates.FLAT_ITEM);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import cuteneko.catsplus.tag.ModItemTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.item.Items;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.core.HolderLookup;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.CompletableFuture;

public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider {
public ModItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
super(output, completableFuture);

public ModItemTagProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> completableFuture, @Nullable BlockTagProvider blockTagProvider) {
super(output, completableFuture, blockTagProvider);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup arg) {
protected void addTags(HolderLookup.Provider provider) {
getOrCreateTagBuilder(ModItemTags.COOKED_FISHES)
.add(Items.COOKED_COD)
.add(Items.COOKED_SALMON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,46 @@
import cuteneko.catsplus.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.item.Items;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Items;

import java.util.concurrent.CompletableFuture;

public class ModRecipeProvider extends FabricRecipeProvider {
public ModRecipeProvider(FabricDataOutput output) {
super(output);

public ModRecipeProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> registriesFuture) {
super(output, registriesFuture);
}

private static <T> String hasTag(TagKey<T> tag) {
return "has_tag_" + tag.id().getNamespace() + "_" + tag.id().getPath();
private static <T> String getHasName(TagKey<T> tag) {
return "has_tag_" + tag.location().getNamespace() + "_" + tag.location().getPath();
}

@Override
public void generate(RecipeExporter exporter) {
ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, ModItems.CAT_BAG.get())
public void buildRecipes(RecipeOutput output) {
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.CAT_BAG.get())
.pattern("LLL")
.pattern("LGL")
.pattern("LLL")
.input('L', Items.LEATHER)
.input('G', Items.GLASS_PANE)
.criterion(hasItem(Items.LEATHER), conditionsFromItem(Items.LEATHER))
.criterion(hasItem(Items.GLASS_PANE), conditionsFromItem(Items.GLASS_PANE))
.offerTo(exporter);
.define('L', Items.LEATHER)
.define('G', Items.GLASS_PANE)
.unlockedBy(getHasName(Items.LEATHER), has(Items.LEATHER))
.unlockedBy(getHasName(Items.GLASS_PANE), has(Items.GLASS_PANE))
.save(output);

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, ModItems.TOTEMEOW.get())
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.TOTEMEOW.get())
.pattern("FFF")
.pattern("FTF")
.pattern("FFF")
.input('F', ItemTags.FISHES)
.input('T', Items.TOTEM_OF_UNDYING)
.criterion(hasTag(ItemTags.FISHES), conditionsFromTag(ItemTags.FISHES))
.criterion(hasItem(Items.TOTEM_OF_UNDYING), conditionsFromItem(Items.TOTEM_OF_UNDYING))
.offerTo(exporter);
.define('F', ItemTags.FISHES)
.define('T', Items.TOTEM_OF_UNDYING)
.unlockedBy(getHasName(ItemTags.FISHES), has(ItemTags.FISHES))
.unlockedBy(getHasName(Items.TOTEM_OF_UNDYING), has(Items.TOTEM_OF_UNDYING))
.save(output);
}
}
Loading

0 comments on commit 3e9e72d

Please sign in to comment.