diff --git a/src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatSweetBerryBushLikePlantBlock.java b/src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatSweetBerryBushLikePlantBlock.java index 36e4d28..42420b3 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatSweetBerryBushLikePlantBlock.java +++ b/src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatSweetBerryBushLikePlantBlock.java @@ -1,6 +1,15 @@ package net.yyc12345.teyvatcraft.blocks; +import java.util.Random; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Fertilizable; +import net.minecraft.block.Material; +import net.minecraft.block.PlantBlock; import net.minecraft.block.SweetBerryBushBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -8,21 +17,31 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.IntProperty; +import net.minecraft.state.property.Properties; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; import net.minecraft.world.World; + public class TeyvatSweetBerryBushLikePlantBlock extends SweetBerryBushBlock { private Item droppedItem; - public TeyvatSweetBerryBushLikePlantBlock(Settings settings, Item droppedItem) { - super(settings); - this.droppedItem = droppedItem; + public TeyvatSweetBerryBushLikePlantBlock() { + super(FabricBlockSettings.of(Material.PLANT).noCollision().breakInstantly().sounds(BlockSoundGroup.SWEET_BERRY_BUSH)); + } + + public void setDroppedItem(Item item) { + droppedItem = item; } @Environment(EnvType.CLIENT) @@ -52,3 +71,4 @@ public class TeyvatSweetBerryBushLikePlantBlock extends SweetBerryBushBlock { return super.onUse(state, world, pos, player, hand, hit); } } + diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java index c847946..e4fa3f1 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java +++ b/src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java @@ -22,8 +22,8 @@ public class BlocksManager { public static final Block WHITE_IRON_CHUNK_ORE = new OreBlock(getOreBlockSettings(2, 3.0f)); public static final Block IRON_CHUNK_ORE = new OreBlock(getOreBlockSettings(1, 3.0f)); public static final Block STARSILVER_ORE = new OreBlock(getOreBlockSettings(1, 2.0f)); - public static final Block NOCTILUCOUS_JADE = new OreBlock(getOreBlockSettings(1, 3.0f)); - public static final Block COR_LAPIS = new OreBlock(getOreBlockSettings(1, 3.0f)); + public static final Block NOCTILUCOUS_JADE_ORE = new OreBlock(getOreBlockSettings(1, 3.0f)); + public static final Block COR_LAPIS_ORE = new OreBlock(getOreBlockSettings(1, 3.0f)); // ==================== crops public static final Block RICE = new TeyvatCropBlock(); @@ -35,21 +35,21 @@ public class BlocksManager { // flower & sweet berry bush like plant public static final Block CALLA_LILY = new TeyvatFlowerLikePlantBlock(); public static final Block DANDELION_SEED = new TeyvatFlowerLikePlantBlock(); - public static final Block JUEYUN_CHILI = new TeyvatSweetBerryBushLikePlantBlock(ItemsManager.JUEYUN_CHILI); + public static final Block JUEYUN_CHILI = new TeyvatSweetBerryBushLikePlantBlock(); public static final Block SMALL_LAMP_GRASS = new TeyvatFlowerLikePlantBlock(); public static final Block MINT = new TeyvatFlowerLikePlantBlock(); public static final Block SWEET_FLOWER = new TeyvatFlowerLikePlantBlock(); - public static final Block BERRY = new TeyvatSweetBerryBushLikePlantBlock(ItemsManager.BERRY); + public static final Block BERRY = new TeyvatSweetBerryBushLikePlantBlock(); public static final Block SNAPDRAGON = new TeyvatFlowerLikePlantBlock(); public static final Block MATSUTAKE = new TeyvatFlowerLikePlantBlock(); public static final Block HORSETAIL = new TeyvatFlowerLikePlantBlock(); public static final Block CECILIA = new TeyvatFlowerLikePlantBlock(); public static final Block GLAZE_LILY = new TeyvatFlowerLikePlantBlock(); public static final Block PHILANEMO_MUSHROOM = new TeyvatFlowerLikePlantBlock(); - public static final Block SILK_FLOWER = new TeyvatSweetBerryBushLikePlantBlock(ItemsManager.SILK_FLOWER); - public static final Block VALBERRY = new TeyvatSweetBerryBushLikePlantBlock(ItemsManager.VALBERRY); + public static final Block SILK_FLOWER = new TeyvatSweetBerryBushLikePlantBlock(); + public static final Block VALBERRY = new TeyvatSweetBerryBushLikePlantBlock(); public static final Block WINDWHEEL_ASTER = new TeyvatFlowerLikePlantBlock(); - public static final Block WOLFHOOK = new TeyvatSweetBerryBushLikePlantBlock(ItemsManager.WOLFHOOK); + public static final Block WOLFHOOK = new TeyvatSweetBerryBushLikePlantBlock(); public static final Block QINGXIN = new TeyvatFlowerLikePlantBlock(); @@ -63,10 +63,15 @@ public class BlocksManager { Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", name), bl); //register block self } - private static void registerTeyvatPlant(Block bl, String name) { - //BlockRenderLayerMap.INSTANCE.putBlock(bl, RenderLayer.getCutoutMipped()); // set transparent display mode + private static void registerTeyvatFlowerLikePlant(Block bl, String name) { + BlockRenderLayerMap.INSTANCE.putBlock(bl, RenderLayer.getCutoutMipped()); // set transparent display mode Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", name), bl); } + private static void registerTeyvatSweetBerryBushLikePlant(Block bl, String name, Item droppedItem) { + BlockRenderLayerMap.INSTANCE.putBlock(bl, RenderLayer.getCutoutMipped()); // set transparent display mode + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", name), bl); + ((TeyvatSweetBerryBushLikePlantBlock)bl).setDroppedItem(droppedItem); + } public static void RegisterAll() { Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "magical_crystal_chunk_ore"), MAGICAL_CRYSTAL_CHUNK_ORE); @@ -74,8 +79,8 @@ public class BlocksManager { Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "white_iron_chunk_ore"), WHITE_IRON_CHUNK_ORE); Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "iron_chunk_ore"), IRON_CHUNK_ORE); Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "starsilver_ore"), STARSILVER_ORE); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "noctilucous_jade_ore"), NOCTILUCOUS_JADE); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "cor_lapis_ore"), COR_LAPIS); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "noctilucous_jade_ore"), NOCTILUCOUS_JADE_ORE); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "cor_lapis_ore"), COR_LAPIS_ORE); // crops registerCrop(RICE, ItemsManager.RICE_SEED, "rice"); @@ -85,24 +90,24 @@ public class BlocksManager { registerCrop(RADISH, ItemsManager.RADISH, "radish"); // flower & sweet berry bush like plant - registerTeyvatPlant(CALLA_LILY, "calla_lily"); - registerTeyvatPlant(DANDELION_SEED, "dandelion_seed"); - registerTeyvatPlant(JUEYUN_CHILI, "jueyun_chili"); - registerTeyvatPlant(SMALL_LAMP_GRASS, "small_lamp_grass"); - registerTeyvatPlant(MINT, "mint"); - registerTeyvatPlant(SWEET_FLOWER, "sweet_flower"); - registerTeyvatPlant(BERRY, "berry"); - registerTeyvatPlant(SNAPDRAGON, "snapdragon"); - registerTeyvatPlant(MATSUTAKE, "matsutake"); - registerTeyvatPlant(HORSETAIL, "horsetail"); - registerTeyvatPlant(CECILIA, "cecilia"); - registerTeyvatPlant(GLAZE_LILY, "glaze_lily"); - registerTeyvatPlant(PHILANEMO_MUSHROOM, "philanemo_mushroom"); - registerTeyvatPlant(SILK_FLOWER, "silk_flower"); - registerTeyvatPlant(VALBERRY, "valberry"); - registerTeyvatPlant(WINDWHEEL_ASTER, "windwheel_aster"); - registerTeyvatPlant(WOLFHOOK, "wolfhook"); - registerTeyvatPlant(QINGXIN, "qingxin"); + registerTeyvatFlowerLikePlant(CALLA_LILY, "calla_lily"); + registerTeyvatFlowerLikePlant(DANDELION_SEED, "dandelion_seed"); + registerTeyvatSweetBerryBushLikePlant(JUEYUN_CHILI, "jueyun_chili", ItemsManager.JUEYUN_CHILI); + registerTeyvatFlowerLikePlant(SMALL_LAMP_GRASS, "small_lamp_grass"); + registerTeyvatFlowerLikePlant(MINT, "mint"); + registerTeyvatFlowerLikePlant(SWEET_FLOWER, "sweet_flower"); + registerTeyvatSweetBerryBushLikePlant(BERRY, "berry", ItemsManager.BERRY); + registerTeyvatFlowerLikePlant(SNAPDRAGON, "snapdragon"); + registerTeyvatFlowerLikePlant(MATSUTAKE, "matsutake"); + registerTeyvatFlowerLikePlant(HORSETAIL, "horsetail"); + registerTeyvatFlowerLikePlant(CECILIA, "cecilia"); + registerTeyvatFlowerLikePlant(GLAZE_LILY, "glaze_lily"); + registerTeyvatFlowerLikePlant(PHILANEMO_MUSHROOM, "philanemo_mushroom"); + registerTeyvatSweetBerryBushLikePlant(SILK_FLOWER, "silk_flower", ItemsManager.SILK_FLOWER); + registerTeyvatSweetBerryBushLikePlant(VALBERRY, "valberry", ItemsManager.VALBERRY); + registerTeyvatFlowerLikePlant(WINDWHEEL_ASTER, "windwheel_aster"); + registerTeyvatSweetBerryBushLikePlant(WOLFHOOK, "wolfhook", ItemsManager.WOLFHOOK); + registerTeyvatFlowerLikePlant(QINGXIN, "qingxin"); } diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java index 5129172..31c190b 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java +++ b/src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java @@ -388,9 +388,9 @@ public class ItemsManager { Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starsilver_ore"), new BlockItem(BlocksManager.STARSILVER_ORE, new Item.Settings().group(ITEMGROUP_MISC))); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "noctilucous_jade_ore"), - new BlockItem(BlocksManager.NOCTILUCOUS_JADE, new Item.Settings().group(ITEMGROUP_MISC))); + new BlockItem(BlocksManager.NOCTILUCOUS_JADE_ORE, new Item.Settings().group(ITEMGROUP_MISC))); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "cor_lapis_ore"), - new BlockItem(BlocksManager.COR_LAPIS, new Item.Settings().group(ITEMGROUP_MISC))); + new BlockItem(BlocksManager.COR_LAPIS_ORE, new Item.Settings().group(ITEMGROUP_MISC))); // crops & plants registerAsCompostableItem("rice", RICE, false); @@ -402,7 +402,7 @@ public class ItemsManager { Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "calla_lily"), CALLA_LILY); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "dandelion_seed"), DANDELION_SEED); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "jueyun_chili"), JUEYUN_CHILI);/* + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "jueyun_chili"), JUEYUN_CHILI); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "small_lamp_grass"), SMALL_LAMP_GRASS); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "mint"), MINT); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "pepper"), PEPPER); @@ -451,7 +451,6 @@ public class ItemsManager { Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "wolfhook"), WOLFHOOK); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "qingxin"), QINGXIN); Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starconch"), STARCONCH); - */ // drops Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "agnidus_agate_sliver"), AGNIDUS_AGATE_SLIVER);