diff --git a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index d425272..8304c28 100644 --- a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,2 +1 @@ -// 1.21 2024-08-01T22:24:42.609971 Loot Tables -b82daccc5f953aaa0327a61f85766c8394427685 data/lingshi/loot_table/blocks/rice.json +// 1.21 2024-08-02T19:21:51.9075616 Loot Tables diff --git a/src/generated/resources/data/lingshi/loot_table/blocks/rice.json b/src/generated/resources/data/lingshi/loot_table/blocks/rice.json deleted file mode 100644 index 783a9fd..0000000 --- a/src/generated/resources/data/lingshi/loot_table/blocks/rice.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "bonus_rolls": 0.0, - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ], - "entries": [ - { - "type": "minecraft:item", - "name": "lingshi:rice" - } - ], - "rolls": 1.0 - } - ], - "random_sequence": "lingshi:blocks/rice" -} \ No newline at end of file diff --git a/src/main/java/mczme/lingshi/common/block/RiceSeedling.java b/src/main/java/mczme/lingshi/common/block/RiceSeedling.java deleted file mode 100644 index 5566664..0000000 --- a/src/main/java/mczme/lingshi/common/block/RiceSeedling.java +++ /dev/null @@ -1,56 +0,0 @@ -package mczme.lingshi.common.block; - -import com.mojang.serialization.MapCodec; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.RandomSource; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.BonemealableBlock; -import net.minecraft.world.level.block.BushBlock; -import net.minecraft.world.level.block.LiquidBlockContainer; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.FluidState; -import org.jetbrains.annotations.Nullable; - -public class RiceSeedling extends BushBlock implements BonemealableBlock, LiquidBlockContainer { - - public RiceSeedling(Properties properties) { - super(properties); - } - - @Override - protected MapCodec codec() { - return null; - } - - @Override - public boolean isValidBonemealTarget(LevelReader pLevel, BlockPos pPos, BlockState pState) { - return false; - } - - @Override - public boolean isBonemealSuccess(Level pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { - return false; - } - - @Override - public void performBonemeal(ServerLevel pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { - - } - - @Override - public boolean canPlaceLiquid(@Nullable Player pPlayer, BlockGetter pLevel, BlockPos pPos, BlockState pState, Fluid pFluid) { - return false; - } - - @Override - public boolean placeLiquid(LevelAccessor pLevel, BlockPos pPos, BlockState pState, FluidState pFluidState) { - return false; - } -} diff --git a/src/main/java/mczme/lingshi/common/block/RiceSeedlingBlock.java b/src/main/java/mczme/lingshi/common/block/RiceSeedlingBlock.java new file mode 100644 index 0000000..340b3cb --- /dev/null +++ b/src/main/java/mczme/lingshi/common/block/RiceSeedlingBlock.java @@ -0,0 +1,202 @@ +package mczme.lingshi.common.block; + +import com.mojang.serialization.MapCodec; +import mczme.lingshi.common.registry.ModBlocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.FluidTags; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; + +public class RiceSeedlingBlock extends BushBlock implements BonemealableBlock, LiquidBlockContainer { + + public static final BooleanProperty EMERGE = BooleanProperty.create("emerge"); + public static final IntegerProperty AGE = BlockStateProperties.AGE_1; + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + public static final VoxelShape[] SHAPE = new VoxelShape[]{ + Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D), + Block.box(2.0D, 0.0D, 2.0D, 14.0D, 16.0D, 14.0D) + }; + + public RiceSeedlingBlock(Properties properties) { + super(properties.noCollission().instabreak().sound(SoundType.CROP).pushReaction(PushReaction.DESTROY).randomTicks()); + this.registerDefaultState(this.defaultBlockState().setValue(EMERGE, false).setValue(AGE, 0).setValue(WATERLOGGED, true)); + } + + public IntegerProperty getAgeProperty() { + return AGE; + } + + protected int getAge(BlockState state) { + return state.getValue(this.getAgeProperty()); + } + + public int getMaxAge() { + return 1; + } + + public BlockState getStateForAge(int pAge) { + return this.defaultBlockState().setValue(this.getAgeProperty(), pAge); + } + + @Override + public void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) { + super.tick(pState, pLevel, pPos, pRandom); + if (!pLevel.isAreaLoaded(pPos, 1)) return; + if (pLevel.getRawBrightness(pPos.above(), 0) >= 6) { + int age = getAge(pState); + boolean isEmerge = pState.getValue(EMERGE); + if (age <= getMaxAge()) { + float f = 12.0F; + if (net.neoforged.neoforge.common.CommonHooks.canCropGrow(pLevel, pPos, pState, pRandom.nextInt((int) (25.0F / f) + 1) == 0)) { + if (age != getMaxAge()) { + pLevel.setBlock(pPos, this.getStateForAge(age + 1), 2); + net.neoforged.neoforge.common.CommonHooks.fireCropGrowPost(pLevel, pPos, pState); + } else if (!isEmerge) { + RiceSeedlingTopBlock topBlock = ModBlocks.RICE_SEEDING_TOP.get(); + if (topBlock.defaultBlockState().canSurvive(pLevel, pPos.above()) && pLevel.isEmptyBlock(pPos.above())) { + pLevel.setBlockAndUpdate(pPos, pState.setValue(EMERGE, true)); + pLevel.setBlockAndUpdate(pPos.above(), topBlock.defaultBlockState()); + net.neoforged.neoforge.common.CommonHooks.fireCropGrowPost(pLevel, pPos, pState); + } + } else if (pLevel.getBlockState(pPos.above()).is(ModBlocks.RICE_SEEDING_TOP.get())) { + if (pLevel.getBlockState(pPos.above()).getValue(RiceSeedlingTopBlock.AGE) == 4) { + pLevel.setBlockAndUpdate(pPos, pState.setValue(WATERLOGGED, false)); + } + } + } + } + } + } + + @Override + public BlockState updateShape(BlockState pState, Direction pFacing, BlockState pFacingState, LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pFacingPos) { + if (!pState.canSurvive(pLevel, pCurrentPos)) { + return Blocks.AIR.defaultBlockState(); + } else { + if (pState.getValue(WATERLOGGED)) { + pLevel.scheduleTick(pCurrentPos, Fluids.WATER, Fluids.WATER.getTickDelay(pLevel)); + } + return super.updateShape(pState, pFacing, pFacingState, pLevel, pCurrentPos, pFacingPos); + } + } + + @Override + protected MapCodec codec() { + return null; + } + + @Override + protected VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + return SHAPE[getAge(pState)]; + } + + @Override + public boolean isValidBonemealTarget(LevelReader pLevel, BlockPos pPos, BlockState pState) { + BlockState upperState = pLevel.getBlockState(pPos.above()); + if (upperState.getBlock() instanceof RiceSeedlingTopBlock) { + return !((RiceSeedlingTopBlock) upperState.getBlock()).isMaxAge(upperState); + } + return true; + } + + @Override + public boolean isBonemealSuccess(Level pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { + return true; + } + + protected int getBonemealAgeIncrease(Level level) { + return Mth.nextInt(level.random, 1, 2); + } + + @Override + public void performBonemeal(ServerLevel pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { + int ageGrowth = Math.min(this.getAge(pState) + this.getBonemealAgeIncrease(pLevel), 4); + if (ageGrowth <= this.getMaxAge()) { + pLevel.setBlockAndUpdate(pPos, pState.setValue(AGE, ageGrowth)); + } else { + BlockState top = pLevel.getBlockState(pPos.above()); + if (top.getBlock() == ModBlocks.RICE_SEEDING_TOP.get()) { + BonemealableBlock growable = (BonemealableBlock) pLevel.getBlockState(pPos.above()).getBlock(); + if (growable.isValidBonemealTarget(pLevel, pPos.above(), top)) { + growable.performBonemeal(pLevel, pLevel.random, pPos.above(), top); + } + if (pLevel.getBlockState(pPos.above()).getValue(RiceSeedlingTopBlock.AGE) == 4) { + pLevel.setBlockAndUpdate(pPos, pState.setValue(WATERLOGGED, false)); + } + } else { + RiceSeedlingTopBlock riceUpper = ModBlocks.RICE_SEEDING_TOP.get(); + int remainingGrowth = ageGrowth - this.getMaxAge() - 1; + if (riceUpper.defaultBlockState().canSurvive(pLevel, pPos.above()) && pLevel.isEmptyBlock(pPos.above())) { + pLevel.setBlockAndUpdate(pPos, pState.setValue(AGE, this.getMaxAge())); + pLevel.setBlockAndUpdate(pPos, pState.setValue(EMERGE, true)); + pLevel.setBlock(pPos.above(), riceUpper.defaultBlockState().setValue(RiceSeedlingTopBlock.AGE, remainingGrowth), 2); + } + } + } + } + + @Override + protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) { + return super.mayPlaceOn(state, level, pos) || state.is(BlockTags.DIRT); + } + + @Override + public boolean canSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos) { + FluidState fluid = pLevel.getFluidState(pPos); + if (pState.getValue(WATERLOGGED)) { + return super.canSurvive(pState, pLevel, pPos) && fluid.is(FluidTags.WATER) && fluid.getAmount() == 8; + } else { + return super.canSurvive(pState, pLevel, pPos); + } + } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockPlaceContext context) { + FluidState fluid = context.getLevel().getFluidState(context.getClickedPos()); + return fluid.is(FluidTags.WATER) && fluid.getAmount() == 8 ? super.getStateForPlacement(context) : null; + } + + @Override + public boolean canPlaceLiquid(@Nullable Player pPlayer, BlockGetter pLevel, BlockPos pPos, BlockState pState, Fluid pFluid) { + return false; + } + + @Override + public boolean placeLiquid(LevelAccessor pLevel, BlockPos pPos, BlockState pState, FluidState pFluidState) { + return false; + } + + @Override + protected FluidState getFluidState(BlockState pState) { + return pState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { + pBuilder.add(EMERGE, AGE, WATERLOGGED); + } +} diff --git a/src/main/java/mczme/lingshi/common/block/RiceSeedlingTopBlock.java b/src/main/java/mczme/lingshi/common/block/RiceSeedlingTopBlock.java new file mode 100644 index 0000000..c1a5e4d --- /dev/null +++ b/src/main/java/mczme/lingshi/common/block/RiceSeedlingTopBlock.java @@ -0,0 +1,86 @@ +package mczme.lingshi.common.block; + +import mczme.lingshi.common.registry.ModBlocks; +import mczme.lingshi.common.registry.ModItems; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class RiceSeedlingTopBlock extends CropBlock { + + public static final IntegerProperty AGE = BlockStateProperties.AGE_4; + private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{ + Block.box(2, 0.0, 2, 14.0, 8.0, 14.0), + Block.box(2, 0.0, 2, 14.0, 10.0, 14.0), + Block.box(2, 0.0, 2, 14.0, 12.0, 14.0), + Block.box(2, 0.0, 2, 14.0, 14.0, 14.0), + Block.box(2, 0.0, 2, 14.0, 16.0, 14.0) + }; + + public RiceSeedlingTopBlock(Properties properties) { + super(properties.noCollission().instabreak().sound(SoundType.CROP).pushReaction(PushReaction.DESTROY).randomTicks()); + this.registerDefaultState(this.defaultBlockState().setValue(AGE, 0)); + } + + @Override + public void destroy(LevelAccessor pLevel, BlockPos pPos, BlockState pState) { + if (pLevel.getBlockState(pPos.below()).getBlock() instanceof RiceSeedlingBlock) { + pLevel.setBlock(pPos.below(), Blocks.AIR.defaultBlockState(), 2); + } + } + + @Override + public IntegerProperty getAgeProperty() { + return AGE; + } + + @Override + public int getAge(BlockState state) { + return state.getValue(this.getAgeProperty()); + } + + @Override + public int getMaxAge() { + return 4; + } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + return SHAPE_BY_AGE[this.getAge(state)]; + } + + + @Override + public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { + return (level.getRawBrightness(pos, 0) >= 8 || level.canSeeSky(pos)) && this.mayPlaceOn(level.getBlockState(pos.below()), level, pos); + } + + @Override + protected ItemLike getBaseSeedId() { + return ModItems.RICE_SEEDLING.get(); + } + + @Override + protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) { + return state.is(ModBlocks.RICE_SEEDLING.get()); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { + pBuilder.add(AGE); + } +} diff --git a/src/main/java/mczme/lingshi/common/createtab/CreateTabs.java b/src/main/java/mczme/lingshi/common/createtab/CreateTabs.java index fe0ab5b..95c7f8e 100644 --- a/src/main/java/mczme/lingshi/common/createtab/CreateTabs.java +++ b/src/main/java/mczme/lingshi/common/createtab/CreateTabs.java @@ -9,17 +9,17 @@ import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; +import static mczme.lingshi.common.registry.ModItems.ITEMS_LIST; import static mczme.lingshi.lingshi.MODID; public class CreateTabs { public static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID); public static final DeferredHolder LINGSHI_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder() - .title(Component.translatable("lingshi.lingshi_tab")) //The language key for the title of your CreativeModeTab + .title(Component.translatable("lingshi.lingshi_tab")) .withTabsBefore(CreativeModeTabs.COMBAT) .icon(() -> ModItems.RICE.get().getDefaultInstance()) .displayItems((parameters, output) -> { - output.accept(ModItems.RICE.get()); - output.accept(ModItems.RICE_SEEDING.get()); + ITEMS_LIST.forEach(item -> output.accept(item.get())); }).build()); public static void register(IEventBus modEventBus) { diff --git a/src/main/java/mczme/lingshi/common/data/DataGenerators.java b/src/main/java/mczme/lingshi/common/data/DataGenerators.java index 1c6453e..2bfaeb2 100644 --- a/src/main/java/mczme/lingshi/common/data/DataGenerators.java +++ b/src/main/java/mczme/lingshi/common/data/DataGenerators.java @@ -30,7 +30,9 @@ public static void onGatherData(GatherDataEvent event) { // block loot event.getGenerator().addProvider( event.includeServer(), - new LootTableProvider(output, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLoot::new, LootContextParamSets.BLOCK)),lookupProvider) + new LootTableProvider(output, Set.of(), + List.of(new LootTableProvider.SubProviderEntry(BlockLoot::new, LootContextParamSets.BLOCK)), + lookupProvider) ); } } diff --git a/src/main/java/mczme/lingshi/common/data/loot/BlockLoot.java b/src/main/java/mczme/lingshi/common/data/loot/BlockLoot.java index a419d07..6848399 100644 --- a/src/main/java/mczme/lingshi/common/data/loot/BlockLoot.java +++ b/src/main/java/mczme/lingshi/common/data/loot/BlockLoot.java @@ -1,6 +1,7 @@ package mczme.lingshi.common.data.loot; import mczme.lingshi.common.registry.ModBlocks; +import mczme.lingshi.common.registry.ModItems; import net.minecraft.core.HolderLookup; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.world.flag.FeatureFlags; @@ -11,7 +12,7 @@ public class BlockLoot extends BlockLootSubProvider { public static final Set BLOCK = Set.of( - ModBlocks.RICE.get() + ); public BlockLoot(HolderLookup.Provider lookupProvider) { @@ -21,7 +22,7 @@ public BlockLoot(HolderLookup.Provider lookupProvider) { @Override protected void generate() { - this.dropSelf(ModBlocks.RICE.get()); + } @Override diff --git a/src/main/java/mczme/lingshi/common/item/RiceSeedlingItem.java b/src/main/java/mczme/lingshi/common/item/RiceSeedlingItem.java new file mode 100644 index 0000000..990d0a9 --- /dev/null +++ b/src/main/java/mczme/lingshi/common/item/RiceSeedlingItem.java @@ -0,0 +1,31 @@ +package mczme.lingshi.common.item; + +import net.minecraft.core.Direction; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemNameBlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.FarmBlock; +import net.minecraft.world.level.block.state.BlockState; + +public class RiceSeedlingItem extends ItemNameBlockItem { + public RiceSeedlingItem(Block block, Properties properties) { + super(block,properties); + } + + @Override + public InteractionResult useOn(UseOnContext context) { + InteractionResult result = this.place(new BlockPlaceContext(context)); + if (result.equals(InteractionResult.FAIL)) { + Player player = context.getPlayer(); + BlockState targetState = context.getLevel().getBlockState(context.getClickedPos()); + if (player != null && context.getClickedFace().equals(Direction.UP) && (targetState.is(BlockTags.DIRT) || targetState.getBlock() instanceof FarmBlock)) { +// player.displayClientMessage(TextUtils.getTranslation("block.rice.invalid_placement"), true); + } + } + return result; + } +} diff --git a/src/main/java/mczme/lingshi/common/registry/ModBlocks.java b/src/main/java/mczme/lingshi/common/registry/ModBlocks.java index 697fe88..3b13e7d 100644 --- a/src/main/java/mczme/lingshi/common/registry/ModBlocks.java +++ b/src/main/java/mczme/lingshi/common/registry/ModBlocks.java @@ -1,6 +1,7 @@ package mczme.lingshi.common.registry; -import mczme.lingshi.common.block.RiceSeedling; +import mczme.lingshi.common.block.RiceSeedlingBlock; +import mczme.lingshi.common.block.RiceSeedlingTopBlock; import mczme.lingshi.lingshi; import net.minecraft.world.level.block.CropBlock; import net.minecraft.world.level.block.SoundType; @@ -22,7 +23,9 @@ public class ModBlocks { .instabreak() .sound(SoundType.CROP) .pushReaction(PushReaction.DESTROY)); - public static final Supplier RICE_SEEDING = BLOCKS.registerBlock("rice_seeding", RiceSeedling::new, + public static final Supplier RICE_SEEDLING = BLOCKS.registerBlock("rice_seedling", RiceSeedlingBlock::new, + BlockBehaviour.Properties.of()); + public static final Supplier RICE_SEEDING_TOP = BLOCKS.registerBlock("rice_seedling_top", RiceSeedlingTopBlock::new, BlockBehaviour.Properties.of()); public static void register(IEventBus modEventBus) { diff --git a/src/main/java/mczme/lingshi/common/registry/ModItems.java b/src/main/java/mczme/lingshi/common/registry/ModItems.java index 03d834f..9702bdf 100644 --- a/src/main/java/mczme/lingshi/common/registry/ModItems.java +++ b/src/main/java/mczme/lingshi/common/registry/ModItems.java @@ -1,18 +1,29 @@ package mczme.lingshi.common.registry; +import mczme.lingshi.common.item.RiceSeedlingItem; import mczme.lingshi.lingshi; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.registries.DeferredRegister; +import java.util.ArrayList; +import java.util.List; import java.util.function.Supplier; public class ModItems { public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(lingshi.MODID); + public static final List> ITEMS_LIST = new ArrayList<>(); - public static final Supplier RICE = ITEMS.registerSimpleBlockItem("rice", ModBlocks.RICE, new Item.Properties()); - public static final Supplier RICE_SEEDING =ITEMS.registerSimpleBlockItem("rice_seeding", ModBlocks.RICE_SEEDING, new Item.Properties()); + public static final Supplier RICE = registerWithCreateTab("rice", ()->new BlockItem(ModBlocks.RICE.get(), new Item.Properties())); + public static final Supplier RICE_SEEDLING =registerWithCreateTab("rice_seedling", ()->new RiceSeedlingItem(ModBlocks.RICE_SEEDLING.get(),new Item.Properties())); + public static final Supplier RICE_OF_EAR = registerWithCreateTab("rice_of_ear", () -> new Item(new Item.Properties())); + + private static Supplier registerWithCreateTab(String item_name, Supplier itemSupplier) { + Supplier item = ITEMS.register(item_name, itemSupplier); + ITEMS_LIST.add(item); + return item; + } public static void register(IEventBus modEventBus) { ITEMS.register(modEventBus); diff --git a/src/main/java/mczme/lingshi/lingshi.java b/src/main/java/mczme/lingshi/lingshi.java index f5bf3c5..52e3837 100644 --- a/src/main/java/mczme/lingshi/lingshi.java +++ b/src/main/java/mczme/lingshi/lingshi.java @@ -19,8 +19,7 @@ public class lingshi private static final Logger LOGGER = LogUtils.getLogger(); - // The constructor for the mod class is the first code that is run when your mod is loaded. - // FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically. + public lingshi(IEventBus modEventBus, ModContainer modContainer) { ModBlocks.register(modEventBus); diff --git a/src/main/resources/assets/lingshi/blockstates/rice.json b/src/main/resources/assets/lingshi/blockstates/rice.json new file mode 100644 index 0000000..b8a6fb9 --- /dev/null +++ b/src/main/resources/assets/lingshi/blockstates/rice.json @@ -0,0 +1,28 @@ +{ + "variants": { + "age=0": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=1": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=2": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=3": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=4": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=5": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=6": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=7": { + "model": "lingshi:block/riceseedling_age0" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/blockstates/rice_seedling.json b/src/main/resources/assets/lingshi/blockstates/rice_seedling.json new file mode 100644 index 0000000..2ec510e --- /dev/null +++ b/src/main/resources/assets/lingshi/blockstates/rice_seedling.json @@ -0,0 +1,16 @@ +{ + "variants": { + "age=0,emerge=false": { + "model": "lingshi:block/riceseedling_age0" + }, + "age=1,emerge=false": { + "model": "lingshi:block/riceseedling_emerge" + }, + "age=0,emerge=true": { + "model": "lingshi:block/riceseedling_emerge" + }, + "age=1,emerge=true": { + "model": "lingshi:block/riceseedling_emerge" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/blockstates/rice_seedling_top.json b/src/main/resources/assets/lingshi/blockstates/rice_seedling_top.json new file mode 100644 index 0000000..c2b7612 --- /dev/null +++ b/src/main/resources/assets/lingshi/blockstates/rice_seedling_top.json @@ -0,0 +1,19 @@ +{ + "variants": { + "age=0": { + "model": "lingshi:block/riceseedling_top_age0" + }, + "age=1": { + "model": "lingshi:block/riceseedling_top_age1" + }, + "age=2": { + "model": "lingshi:block/riceseedling_top_age2" + }, + "age=3": { + "model": "lingshi:block/riceseedling_top_age3" + }, + "age=4": { + "model": "lingshi:block/riceseedling_top_age4" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/lang/zh_cn.json b/src/main/resources/assets/lingshi/lang/zh_cn.json index 748e3d9..8e06d42 100644 --- a/src/main/resources/assets/lingshi/lang/zh_cn.json +++ b/src/main/resources/assets/lingshi/lang/zh_cn.json @@ -1,5 +1,7 @@ { "lingshi.lingshi_tab": "灵食", "block.lingshi.rice": "稻米", - "block.lingshi.rice_seeding": "稻苗" + "item.lingshi.rice_seedling": "稻苗", + "item.lingshi.rice_of_ear": "稻穗" + } \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/rice.json b/src/main/resources/assets/lingshi/models/block/rice.json new file mode 100644 index 0000000..e1f6101 --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/rice.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_age0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/riceseedling_age0.json b/src/main/resources/assets/lingshi/models/block/riceseedling_age0.json new file mode 100644 index 0000000..e1f6101 --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/riceseedling_age0.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_age0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/riceseedling_emerge.json b/src/main/resources/assets/lingshi/models/block/riceseedling_emerge.json new file mode 100644 index 0000000..90280fc --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/riceseedling_emerge.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_emerge" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/riceseedling_top_age0.json b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age0.json new file mode 100644 index 0000000..087728b --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age0.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_top_age0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/riceseedling_top_age1.json b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age1.json new file mode 100644 index 0000000..087728b --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age1.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_top_age0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/riceseedling_top_age2.json b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age2.json new file mode 100644 index 0000000..dc451ff --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age2.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_top_age1" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/riceseedling_top_age3.json b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age3.json new file mode 100644 index 0000000..dc451ff --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age3.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_top_age1" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/models/block/riceseedling_top_age4.json b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age4.json new file mode 100644 index 0000000..c9f8923 --- /dev/null +++ b/src/main/resources/assets/lingshi/models/block/riceseedling_top_age4.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "minecraft:cutout", + "textures": { + "cross": "lingshi:block/riceseedling_top_age3" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lingshi/textures/block/riceseedling_age0.png b/src/main/resources/assets/lingshi/textures/block/riceseedling_age0.png new file mode 100644 index 0000000..003b808 Binary files /dev/null and b/src/main/resources/assets/lingshi/textures/block/riceseedling_age0.png differ diff --git a/src/main/resources/assets/lingshi/textures/block/riceseedling_emerge.png b/src/main/resources/assets/lingshi/textures/block/riceseedling_emerge.png new file mode 100644 index 0000000..6e63793 Binary files /dev/null and b/src/main/resources/assets/lingshi/textures/block/riceseedling_emerge.png differ diff --git a/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age0.png b/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age0.png new file mode 100644 index 0000000..3633857 Binary files /dev/null and b/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age0.png differ diff --git a/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age1.png b/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age1.png new file mode 100644 index 0000000..71f8f6a Binary files /dev/null and b/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age1.png differ diff --git a/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age3.png b/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age3.png new file mode 100644 index 0000000..022b98c Binary files /dev/null and b/src/main/resources/assets/lingshi/textures/block/riceseedling_top_age3.png differ diff --git a/src/main/resources/data/lingshi/loot_table/blocks/rice.json b/src/main/resources/data/lingshi/loot_table/blocks/rice.json new file mode 100644 index 0000000..178cf53 --- /dev/null +++ b/src/main/resources/data/lingshi/loot_table/blocks/rice.json @@ -0,0 +1,46 @@ +{ + "pools": [ + { + "rolls": { + "min": 3, + "max": 5 + }, + "entries": [ + { + "type": "minecraft:item", + "name": "lingshi:rice_seedling", + "conditions": [ + { + "condition": "minecraft:block_state_property", + "block": "lingshi:rice", + "properties": { + "age": "7" + } + } + ] + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "lingshi:rice" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:block_state_property", + "block": "lingshi:rice", + "properties": { + "age": "7" + } + } + } + ] + } + ] +} diff --git a/src/main/resources/data/lingshi/loot_table/blocks/rice_seedling.json b/src/main/resources/data/lingshi/loot_table/blocks/rice_seedling.json new file mode 100644 index 0000000..854f93f --- /dev/null +++ b/src/main/resources/data/lingshi/loot_table/blocks/rice_seedling.json @@ -0,0 +1,26 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "lingshi:rice_seedling", + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:block_state_property", + "block": "lingshi:rice_seedling", + "properties": { + "age": "1" + } + } + } + ] + } + ] + } + ] +} diff --git a/src/main/resources/data/lingshi/loot_table/blocks/rice_seedling_top.json b/src/main/resources/data/lingshi/loot_table/blocks/rice_seedling_top.json new file mode 100644 index 0000000..ee5f3c5 --- /dev/null +++ b/src/main/resources/data/lingshi/loot_table/blocks/rice_seedling_top.json @@ -0,0 +1,25 @@ +{ + "pools": [ + { + "rolls": { + "min": 3, + "max": 5 + }, + "entries": [ + { + "type": "minecraft:item", + "name": "lingshi:rice_of_ear", + "conditions": [ + { + "condition": "minecraft:block_state_property", + "block": "lingshi:rice_seedling_top", + "properties": { + "age": "4" + } + } + ] + } + ] + } + ] +}