Crops Help

Started by The_Nexus300 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Crops Help
Fri, 04/10/2026 - 17:40 (edited)

Hey so im having trouble trying to make crops accurate to the rest of the game. So far its been going pretty well using integer properties and blockstates. My issues start at Harvesting using either a loottable together with a "Harvest condition" procedure, or a "when block is destroyed by player" procedure. Neither option seems to yield the behaviour im looking for. 

 

When using a loot table, it completely seems to ignore the Harvest condition when the crop is destroyed via the environment i.e water, or the block underneath it being broken ect..., leading to it granting the full loot as if it were fully grown, regardless of how old the crop actually was. 

 

When using the "when block is destroyed by player" procedure, it obviously only gets called when destroyed by the player specifically, so your usual vanilla farms that get mass harvested with water systems wouldnt work on my crop at all, destroying them with granting anything.

 

I was wondering if anyone could help me figure out a method to achieve all the behaviours im looking for, either through plugins or whatever :)

Edited by The_Nexus300 on Fri, 04/10/2026 - 17:40
Hmm, you may need to code…
Sat, 04/11/2026 - 15:49

Hmm, you may need to code custom loot table.

I though we had general block broken trigger. Maybe there is a global one?

Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for the reply :) So i…
Sat, 04/11/2026 - 20:42

Thanks for the reply :) 

So i definitely couldnt find a general block broken trigger. But i did find the global one. It worked when the player breaks the crop, but for whatever reason it also doesnt seem to call the procedure when broken by the environment like, water or invalid placement.

Im willing to code my custom loot table, so im off to youtube to find some tutorials haha

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok, you'll need to make some…
Tue, 06/30/2026 - 23:33

Ok, you'll need to make some code change to make crops work properly.  Thankfully with 2026.1 it's simple.

 

First setup a new Plant the way you want it.  Once saved, lock it and open the code [PlantBlock.java] or whatever you named it.  Now make the following changes 

coide

 

This will create a crop with 7 ages like a vanilla crop.

Next navigate to Resources\data\MODNAME\loot_table\blocks and open the plant.json that corresponds to your new crop.

Now use the following example to make your crop drops based on the age (age=7 is mature)

 

{
	"type": "minecraft:block",
	"pools": [
		{
			"rolls": 1,
			"entries": [
				{
					"type": "minecraft:item",
					"name": "kolaches:plant_tomato",
					"weight": 1,
					"functions": [
						{
							"function": "minecraft:set_count",
							"count": {
								"min": 1,
								"max": 1
							}
						}
					]
				}
			]
		},
		{
			"rolls": 1,
			"entries": [
				{
					"type": "minecraft:item",
					"name": "kolaches:fruits_tomato",
					"conditions": [
						{
							"condition": "minecraft:block_state_property",
							"block": "kolaches:plant_tomato",
							"properties": {
								"age": "7"
							}
						}
					],
					"weight": 1,
					"functions": [
						{
							"function": "minecraft:set_count",
							"count": {
								"min": 1,
								"max": 3
							}
						}
					]
				}
			]
		}
	],
	"random_sequence": "kolaches:blocks/plant_tomato"
}

 

Don't forget to add the correct block state images in Resources\assets\MODNAME\blockstates and use the following example:

 

{
	"variants": {
		"age=0": {
			"model": "kolaches:block/plant_tomato_0"
		},
		"age=1": {
			"model": "kolaches:block/plant_tomato_1"
		},
		"age=2": {
			"model": "kolaches:block/plant_tomato_2"
		},
		"age=3": {
			"model": "kolaches:block/plant_tomato_3"
		},
		"age=4": {
			"model": "kolaches:block/plant_tomato_4"
		},
		"age=5": {
			"model": "kolaches:block/plant_tomato_5"
		},
		"age=6": {
			"model": "kolaches:block/plant_tomato_6"
		},
		"age=7": {
			"model": "kolaches:block/plant_tomato_7"
		}
	}
}	
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Forgot to add:   It would be…
Tue, 06/30/2026 - 23:36

Forgot to add:

 

It would be great if these changes could be made in the Plant element in mcreator so that updating/upgrading wouldn't require unlocking and making the changes again.