Skip to content

Commit

Permalink
🐛 修倍datagen
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuRuoLing committed Sep 6, 2024
1 parent c5e96a9 commit fb3d29f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public T build() {
@Override
public BlockEntry<T> register() {
if (this.recipeFunction != null){
System.out.println("register itemBuilder = " + itemBuilder);
this.itemBuilder.recipe(
(itemEntry1, registratorRecipeProvider) -> recipeFunction.accept(itemEntry1, registratorRecipeProvider)
);
Expand All @@ -152,7 +153,7 @@ public BlockEntry<T> register() {
}

public BlockBuilder<T> recipe(BiConsumer<ItemEntry<? extends BlockItem>, RegistratorRecipeProvider> fn) {
itemBuilder.recipe(fn::accept);
System.out.println("itemBuilder = " + itemBuilder);
this.recipeFunction = fn;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.anvilcraft.lib.registrator.builder.BlockBuilder;
import dev.anvilcraft.lib.registrator.builder.ItemBuilder;
import lombok.Getter;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
Expand All @@ -14,6 +15,7 @@

public class BlockEntry<T extends Block> extends RegistryEntry<T> implements ItemLike {
private final BlockBuilder<T> blockBuilder;
@Getter
private ItemEntry<? extends BlockItem> blockItem = null;

public BlockEntry(BlockBuilder<T> blockBuilder) {
Expand Down
10 changes: 10 additions & 0 deletions fabric/src/test/java/dev/anvilcraft/lib/test/TestRegisters.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ public class TestRegisters {
public static final BlockEntry<Block> TEST_BLOCK = REGISTRATOR
.block("test_block", Block::new)
.tag(TEST_BLOCK_TAG)
.recipe((e, p) -> {
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, e)
.pattern("xxx")
.pattern("xxx")
.pattern("xxx")
.define('x', TEST_ITEM.asItem())
.unlockedBy("has_apple", RecipeProvider.has(Items.APPLE))
.save(p);
})
.defaultItem()
.register();

Expand All @@ -51,5 +60,6 @@ public class TestRegisters {
.register();

public static void register() {
System.out.println("TEST_BLOCK.getBlockItem().builder() = " + TEST_BLOCK.getBlockItem().getItemBuilder());
}
}

0 comments on commit fb3d29f

Please sign in to comment.