Skip to content

Commit b635b0f

Browse files
committed
Simplify hearty grain harvesting
1 parent ed2c379 commit b635b0f

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

common/src/main/kotlin/accieo/cobbleworkers/utilities/CobbleworkersCropUtils.kt

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ object CobbleworkersCropUtils {
9898
/**
9999
* Executes the complete harvesting processes for a single crop
100100
*/
101+
// TODO: Clean this whole function
101102
fun harvestCrop(world: World, blockPos: BlockPos, pokemonEntity: PokemonEntity, pokemonHeldItems: MutableMap<UUID, List<ItemStack>>, config: CobbleworkersConfig.CropHarvestGroup) {
102103
val blockState = world.getBlockState(blockPos)
103104
if (blockState.block !in validCropBlocks) return
@@ -123,23 +124,12 @@ object CobbleworkersCropUtils {
123124
val isRice = blockId == FarmersDelightBlocks.RICE_PANICLES
124125
val isMushroomColony = blockId in FarmersDelightBlocks.MUSHROOMS
125126

126-
// TODO: Clean this whole function
127-
// This is super ugly, but it's a multi-block crop...
128127
if (block == CobblemonBlocks.HEARTY_GRAINS) {
129128
val belowPos = blockPos.down()
130129
val belowState = world.getBlockState(belowPos)
131-
132-
world.setBlockState(
133-
belowPos,
134-
belowState.with(
135-
HeartyGrainsBlock.AGE,
136-
HeartyGrainsBlock.AGE_AFTER_HARVEST
137-
),
138-
Block.NOTIFY_LISTENERS
139-
)
140-
141-
world.setBlockState(blockPos, Blocks.AIR.defaultState, Block.NOTIFY_LISTENERS)
142-
130+
if (belowState.block == CobblemonBlocks.HEARTY_GRAINS) {
131+
world.setBlockState(blockPos, Blocks.AIR.defaultState, Block.NOTIFY_LISTENERS)
132+
}
143133
return
144134
}
145135

0 commit comments

Comments
 (0)