Posted March 17, 20205 yr comment_388900 I am creating a custom netherrack grass block (warped nylium) I would like the block to turn into netherrack after placing a block on top. I would also want grass and flowers to be placeable on it. Also, any ideas on how to make it spreadable? So far, I got the block to register with textures and everything, but I could find any tutorials on getting grass functionality for it Thanks Here is the block's class so far: public class WarpedNylium extends GrassBlock { public WarpedNylium() { super(Properties.create(Material.ORGANIC) .sound(SoundType.STONE) .hardnessAndResistance(0.4F) .harvestTool(ToolType.PICKAXE) ); setRegistryName("warped_nylium"); } }
March 17, 20205 yr comment_388908 Hi I very much doubt you'll find a specific tutorial for this, I think you'll probably have to spend some time understanding the vanilla code. Some of the key words to help your search: Block.canSustainPlant() BushBlock GrassBlock.grow() SpreadableSnowyDirtBlock.tick() -TGG
March 17, 20205 yr Author comment_388910 I found GrassBlock.grow() and GrassBlock.canGrow() The first one returns a void datatype and the second one returns a boolean datatype I overridden the second method to return true, but there was no change Here is the code now: public class WarpedNylium extends GrassBlock { public WarpedNylium() { super(Properties.create(Material.ORGANIC) .sound(SoundType.STONE) .hardnessAndResistance(0.4F) .harvestTool(ToolType.PICKAXE) ); setRegistryName("warped_nylium"); } @Override public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) { return true; } } I am unsure on how to override the grow() method, since it looks complicated: public void grow(World worldIn, Random rand, BlockPos pos, BlockState state) { BlockPos blockpos = pos.up(); BlockState blockstate = Blocks.GRASS.getDefaultState(); for(int i = 0; i < 128; ++i) { BlockPos blockpos1 = blockpos; int j = 0; while(true) { if (j >= i / 16) { BlockState blockstate2 = worldIn.getBlockState(blockpos1); if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) { ((IGrowable)blockstate.getBlock()).grow(worldIn, rand, blockpos1, blockstate2); } if (!blockstate2.isAir()) { break; } BlockState blockstate1; if (rand.nextInt(8) == 0) { List<ConfiguredFeature<?>> list = worldIn.getBiome(blockpos1).getFlowers(); if (list.isEmpty()) { break; } blockstate1 = ((FlowersFeature)((DecoratedFeatureConfig)(list.get(0)).config).feature.feature).getRandomFlower(rand, blockpos1); } else { blockstate1 = blockstate; } if (blockstate1.isValidPosition(worldIn, blockpos1)) { worldIn.setBlockState(blockpos1, blockstate1, 3); } break; } blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1); if (worldIn.getBlockState(blockpos1.down()).getBlock() != this || worldIn.getBlockState(blockpos1).func_224756_o(worldIn, blockpos1)) { break; } ++j; } } } Thanks for the help Edit: I found the canSustainPlant() method but I think it could be deprecated, correct me if I am wrong Edited March 17, 20205 yr by abdmoh123 Spelling
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.