Skip to content

Commit

Permalink
🌟 更新注册 API
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Sep 4, 2024
1 parent 9d1b4fb commit 6c0a8b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemModelFile> {
public AnvilLibItemModelProvider(
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6c0a8b3

Please sign in to comment.