[ad_1]
I’ve been working by way of this tutorial.
My code appears to be like one thing like this:
public class OnionBlock extends CropBlock {
non-public static closing VoxelShape[] AGE_TO_SHAPE = new VoxelShape[]{Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D),
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D),
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D),
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 5.0D, 16.0D),
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D),
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D),
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D),
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D)
};
public OnionBlock(SummaryBlock.Settings settings) {
tremendous(settings);
}
public ItemConvertible getSeedsItem() {
return HardestCore.ONION_SEEDS;
}
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return AGE_TO_SHAPE[(Integer)state.get(this.getAgeProperty())];
}
}
The entry level appears to be like like this:
public void onInitialize() {
Registry.register(Registry.BLOCK, new Identifier("hardestcore","onion_block"), ONION_BLOCK);
Registry.register(Registry.ITEM, new Identifier("hardestcore","onion_seeds"), ONION_SEEDS);
Registry.register(Registry.ITEM, new Identifier("hardestcore", "onion"), ONION);
BlockRenderLayerMap.INSTANCE.putBlock(ONION_BLOCK, RenderLayer.getCutout());
CompostingChanceRegistry.INSTANCE.add(ONION, 0.1f);
VillagerPlantableRegistry.register(ONION_SEEDS);
}
This principally works. You can plant the seeds, bonemealing them makes the plant mature, and so on. However, it isn’t clear what a part of the code is meant to trigger the damaged ripe/mature crop to drop seeds/meals. There are a number of Youtube movies that supposedly illustrate this, however attempt as I’d I can by no means pause the movies at a degree the place I can learn and make sense of their code.
I believe I’m lacking one thing solely.
[ad_2]