From 6531ecc185e7cd06d80d419b74c4b26530908992 Mon Sep 17 00:00:00 2001 From: Settordici <63635493+Settordici@users.noreply.github.com> Date: Wed, 20 Apr 2022 22:28:37 +0200 Subject: [PATCH] Added growth for little grass --- .../beautify/block/custom/LittleGrass.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/Settordici/beautify/block/custom/LittleGrass.java b/src/main/java/net/Settordici/beautify/block/custom/LittleGrass.java index 9687e70..5044e80 100644 --- a/src/main/java/net/Settordici/beautify/block/custom/LittleGrass.java +++ b/src/main/java/net/Settordici/beautify/block/custom/LittleGrass.java @@ -1,14 +1,15 @@ package net.Settordici.beautify.block.custom; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.PlantBlock; -import net.minecraft.block.ShapeContext; +import net.minecraft.block.*; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; +import net.minecraft.world.World; -public class LittleGrass extends PlantBlock { +import java.util.Random; + +public class LittleGrass extends PlantBlock implements Fertilizable{ public LittleGrass(Settings settings) { super(settings); @@ -24,6 +25,24 @@ public OffsetType getOffsetType() { return OffsetType.XZ; } + @Override + public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { + return true; + } + + @Override + public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + return true; + } + + @Override + public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + //BlockPos pos_ = new BlockPos(pos); + BlockState state_ = Blocks.GRASS.getDefaultState(); + world.setBlockState(pos, state_); + } + + /*@Override protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { return super.canPlantOnTop(floor, world, pos);