From 6c0a8b3102487347e3ccda1da5ebbfc00cde71ca Mon Sep 17 00:00:00 2001 From: Gugle Date: Wed, 4 Sep 2024 12:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20=E6=9B=B4=E6=96=B0=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/data/provider/AnvilLibItemModelProvider.java | 6 ++++-- .../dev/anvilcraft/lib/data/provider/LanguageProvider.java | 2 +- .../test/java/dev/anvilcraft/lib/test/TestRegisters.java | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/dev/anvilcraft/lib/data/provider/AnvilLibItemModelProvider.java b/common/src/main/java/dev/anvilcraft/lib/data/provider/AnvilLibItemModelProvider.java index 8de0832..c627d7f 100644 --- a/common/src/main/java/dev/anvilcraft/lib/data/provider/AnvilLibItemModelProvider.java +++ b/common/src/main/java/dev/anvilcraft/lib/data/provider/AnvilLibItemModelProvider.java @@ -5,6 +5,8 @@ import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; +import net.minecraft.world.level.ItemLike; +import org.jetbrains.annotations.NotNull; public class AnvilLibItemModelProvider extends ModelProvider { public AnvilLibItemModelProvider( @@ -20,8 +22,8 @@ String getProviderName() { return "ItemModel"; } - public ItemModelFile simple(Item item) { - return simple(BuiltInRegistries.ITEM.getKey(item)); + public ItemModelFile simple(@NotNull ItemLike item) { + return simple(BuiltInRegistries.ITEM.getKey(item.asItem())); } public ItemModelFile simple(ResourceLocation location) { diff --git a/common/src/main/java/dev/anvilcraft/lib/data/provider/LanguageProvider.java b/common/src/main/java/dev/anvilcraft/lib/data/provider/LanguageProvider.java index baed4dd..f4c6a67 100644 --- a/common/src/main/java/dev/anvilcraft/lib/data/provider/LanguageProvider.java +++ b/common/src/main/java/dev/anvilcraft/lib/data/provider/LanguageProvider.java @@ -37,8 +37,8 @@ protected void add(@NotNull TranslationBuilder builder) { } public void add(String translationKey, String value) { - if (value == null) this.translations.remove(translationKey); this.translations.put(translationKey, value); + if (value == null) this.translations.remove(translationKey); } public LanguageProvider(PackOutput dataOutput, String namespace) { diff --git a/fabric/src/test/java/dev/anvilcraft/lib/test/TestRegisters.java b/fabric/src/test/java/dev/anvilcraft/lib/test/TestRegisters.java index 956574e..0b8a576 100644 --- a/fabric/src/test/java/dev/anvilcraft/lib/test/TestRegisters.java +++ b/fabric/src/test/java/dev/anvilcraft/lib/test/TestRegisters.java @@ -25,8 +25,7 @@ public class TestRegisters { .item("test", Item::new) .tag(TEST_ITEM_TAG) .initProperties(() -> Items.APPLE) - .model((entry, provider) -> { - }) + .model((entry, provider) -> provider.simple(entry)) .recipe((entry, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, entry) .pattern("xxx") .pattern("xxx")