Monday, October 31, 2022
HomeGame DevelopmentIn Minecraft (Cloth), how do you register a crop such that breaking...

In Minecraft (Cloth), how do you register a crop such that breaking it’s going to produce seeds and meals gadgets?


I have been working via this tutorial.

My code appears one thing like this:

public class OnionBlock extends CropBlock {
    non-public static remaining 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(AbstractBlock.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 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 largely works. You may plant the seeds, bonemealing them makes the plant mature, and many others. Nevertheless, 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 strive as I would I can by no means pause the movies at some extent the place I can learn and make sense of their code.

I think I am lacking one thing fully.

[edit]

I am lacking the loot desk.

That is for 1.19.2, ought to that matter. I’ve received the next loot desk file, which not less than would not throw errors when Minecraft makes an attempt to parse it:

{
    "swimming pools": [
        {
            "rolls": 1.0,
            "conditions": [
                {
                  "block": "hardestcore:onion_block",
                  "condition": "minecraft:block_state_property",
                  "properties": {
                    "age": "2"
                  }
                }
            ],
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:coal",
                    "weight": 1
                },
                {
                    "type": "item",
                    "name": "minecraft:diamond",
                    "weight": 1
                }
            ]
        }
    ]
}

If the "situations" property is eliminated, this even works… you may smash the plant (any age), and get one of many drops. Nevertheless, I do not appear to have the ability to power it to make use of the situation (or any situation, for that matter). I do not assume I’ve received the namespacing proper.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments