Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

注册新方块,物品 #208

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 73 additions & 5 deletions common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.level.block.StairBlock;
import net.minecraft.world.level.block.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

别用*导入,建议修改写idea的编辑器设置

import net.minecraft.world.level.block.state.BlockBehaviour;

import static dev.dubhe.anvilcraft.AnvilCraft.REGISTRATE;
Expand Down Expand Up @@ -257,6 +253,78 @@ public class ModBlocks {
.unlockedBy(AnvilCraftDatagen.hasItem(ModItems.CURSED_GOLD_INGOT.get()), AnvilCraftDatagen.has(ModItems.CURSED_GOLD_INGOT))
.save(provider))
.register();
public static final BlockEntry<? extends Block> TOPAZ_BLOCK = REGISTRATE
.block("topaz_block", Block::new)
.initialProperties(() -> Blocks.EMERALD_BLOCK)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
.pattern("AAA")
.define('A', ModItems.TOPAZ)
.unlockedBy(AnvilCraftDatagen.hasItem(ModItems.TOPAZ.get()), AnvilCraftDatagen.has(ModItems.TOPAZ))
.save(provider))
.register();
public static final BlockEntry<? extends Block> RUBY_BLOCK = REGISTRATE
.block("ruby_block", Block::new)
.initialProperties(() -> Blocks.EMERALD_BLOCK)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
.pattern("AAA")
.define('A', ModItems.RUBY)
.unlockedBy(AnvilCraftDatagen.hasItem(ModItems.RUBY.get()), AnvilCraftDatagen.has(ModItems.RUBY))
.save(provider))
.register();
public static final BlockEntry<? extends Block> SAPPHIRE_BLOCK = REGISTRATE
.block("sapphire_block", Block::new)
.initialProperties(() -> Blocks.EMERALD_BLOCK)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
.pattern("AAA")
.define('A', ModItems.SAPPHIRE)
.unlockedBy(AnvilCraftDatagen.hasItem(ModItems.SAPPHIRE.get()), AnvilCraftDatagen.has(ModItems.SAPPHIRE))
.save(provider))
.register();
public static final BlockEntry<? extends Block> RESIN_BLOCK = REGISTRATE
.block("resin_block", SlimeBlock::new)
.initialProperties(() -> Blocks.SLIME_BLOCK)
.properties(properties->properties)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
.pattern("AAA")
.define('A', ModItems.RESIN)
.unlockedBy(AnvilCraftDatagen.hasItem(ModItems.RESIN.get()), AnvilCraftDatagen.has(ModItems.RESIN))
.save(provider))
.register();
public static final BlockEntry<? extends Block> AMBER_BLOCK = REGISTRATE
.block("amber_block", HalfTransparentBlock::new)
.initialProperties(() -> Blocks.EMERALD_BLOCK)
.properties(BlockBehaviour.Properties::noOcclusion)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
.pattern("AAA")
.define('A', ModItems.AMBER)
.unlockedBy(AnvilCraftDatagen.hasItem(ModItems.AMBER.get()), AnvilCraftDatagen.has(ModItems.AMBER))
.save(provider))
.register();

public static void register() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class ModItemGroups {
entries.accept(ModItems.TOPAZ.get().getDefaultInstance());
entries.accept(ModItems.RUBY.get().getDefaultInstance());
entries.accept(ModItems.SAPPHIRE.get().getDefaultInstance());
entries.accept(ModItems.RESIN.get().getDefaultInstance());
entries.accept(ModItems.AMBER.get().getDefaultInstance());
entries.accept(ModItems.SPONGE_GEMMULE.get().getDefaultInstance());
entries.accept(ModItems.COCOA_LIQUOR.get().getDefaultInstance());
entries.accept(ModItems.COCOA_BUTTER.get().getDefaultInstance());
Expand Down Expand Up @@ -70,6 +72,11 @@ public class ModItemGroups {
entries.accept(ModBlocks.CUT_ROYAL_STEEL_SLAB.asStack());
entries.accept(ModBlocks.CUT_ROYAL_STEEL_STAIRS.asStack());
entries.accept(ModBlocks.CURSED_GOLD_BLOCK.asStack());
entries.accept(ModBlocks.TOPAZ_BLOCK.asStack());
entries.accept(ModBlocks.RUBY_BLOCK.asStack());
entries.accept(ModBlocks.SAPPHIRE_BLOCK.asStack());
entries.accept(ModBlocks.RESIN_BLOCK.asStack());
entries.accept(ModBlocks.AMBER_BLOCK.asStack());
})
.build()
)
Expand Down
31 changes: 31 additions & 0 deletions common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,43 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, @No
.register();
public static final ItemEntry<TopazItem> TOPAZ = REGISTRATE
.item("topaz", TopazItem::new)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.TOPAZ_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.TOPAZ_BLOCK))
.save(provider)
)
.register();
public static final ItemEntry<Item> RUBY = REGISTRATE
.item("ruby", Item::new)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.RUBY_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.RUBY_BLOCK))
.save(provider)
)
.register();
public static final ItemEntry<Item> SAPPHIRE = REGISTRATE
.item("sapphire", Item::new)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.SAPPHIRE_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.SAPPHIRE_BLOCK))
.save(provider)
)
.register();
public static final ItemEntry<Item> RESIN = REGISTRATE
.item("resin", Item::new)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.RESIN_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.RESIN_BLOCK))
.save(provider)
)
.register();
public static final ItemEntry<Item> AMBER = REGISTRATE
.item("amber", Item::new)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.AMBER_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.AMBER_BLOCK))
.save(provider)
)
.register();

public static void register() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_all",
"render_type": "translucent",
"textures": {
"all": "anvilcraft:block/amber_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_all",
"render_type": "translucent",
"textures": {
"all": "anvilcraft:block/resin_block"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public class AnvilCraftClient implements ClientModInitializer {
public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.HOLLOW_MAGNET_BLOCK.get(), RenderType.cutout());
// BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.CHUTE.get(), RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.RESIN_BLOCK.get(), RenderType.translucent());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.AMBER_BLOCK.get(), RenderType.translucent());
}
}
Loading