1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| package net.tutorialmod.block;
import dev.architectury.registry.registries.DeferredRegister; import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.core.registries.Registries; import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.tutorialmod.TutorialMod; import net.tutorialmod.block.custom.JumpyBlock; import net.tutorialmod.item.ModCreativeTab; import net.tutorialmod.item.ModItem;
import java.util.function.Supplier;
public class ModBlock {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(TutorialMod.MOD_ID, Registries.BLOCK);
public static final RegistrySupplier<Block> ZIRCON_BLOCK = registerBlock("zircon_block",()->new Block(BlockBehaviour.Properties.copy(Blocks.STONE))); public static final RegistrySupplier<Block> JUMPY_BLOCK = registerBlock("jumpy_block",()-> new JumpyBlock(BlockBehaviour.Properties.copy(Blocks.STONE))); public static final RegistrySupplier<Block> ZIRCON_ORE = registerBlock("zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7))); public static final RegistrySupplier<Block> DEEPSLATE_ZIRCON_ORE = registerBlock("deepslate_zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7))); public static final RegistrySupplier<Block> ENDSTONE_ZIRCON_ORE = registerBlock("endstone_zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7))); public static final RegistrySupplier<Block> NETHERRACK_ZIRCON_ORE = registerBlock("netherrack_zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7)));
private static <T extends Block> RegistrySupplier<T> registerBlock(String name, Supplier<T> block) { RegistrySupplier<T> toReturn = BLOCKS.register(name, block); registerBlockItem(name, toReturn); return toReturn;
}
private static <T extends Block> RegistrySupplier<Item> registerBlockItem(String name, RegistrySupplier<T> block) { return ModItem.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().arch$tab(ModCreativeTab.EXAMPLE_TAB))); }
public static void register(){ BLOCKS.register(); }
} package net.tutorialmod.block;
import dev.architectury.registry.registries.DeferredRegister; import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.core.registries.Registries; import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.tutorialmod.TutorialMod; import net.tutorialmod.block.custom.JumpyBlock; import net.tutorialmod.item.ModCreativeTab; import net.tutorialmod.item.ModItem;
import java.util.function.Supplier;
public class ModBlock {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(TutorialMod.MOD_ID, Registries.BLOCK);
public static final RegistrySupplier<Block> ZIRCON_BLOCK = registerBlock("zircon_block",()->new Block(BlockBehaviour.Properties.copy(Blocks.STONE))); public static final RegistrySupplier<Block> JUMPY_BLOCK = registerBlock("jumpy_block",()-> new JumpyBlock(BlockBehaviour.Properties.copy(Blocks.STONE))); public static final RegistrySupplier<Block> ZIRCON_ORE = registerBlock("zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7))); public static final RegistrySupplier<Block> DEEPSLATE_ZIRCON_ORE = registerBlock("deepslate_zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7))); public static final RegistrySupplier<Block> ENDSTONE_ZIRCON_ORE = registerBlock("endstone_zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7))); public static final RegistrySupplier<Block> NETHERRACK_ZIRCON_ORE = registerBlock("netherrack_zircon_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE) .strength(6f).requiresCorrectToolForDrops(), UniformInt.of(3, 7)));
private static <T extends Block> RegistrySupplier<T> registerBlock(String name, Supplier<T> block) { RegistrySupplier<T> toReturn = BLOCKS.register(name, block); registerBlockItem(name, toReturn); return toReturn;
}
private static <T extends Block> RegistrySupplier<Item> registerBlockItem(String name, RegistrySupplier<T> block) { return ModItem.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().arch$tab(ModCreativeTab.EXAMPLE_TAB))); }
public static void register(){ BLOCKS.register(); }
}
|