Disabling sugar cane seed will now break the bottom block

This commit is contained in:
Cameron Reed 2023-02-19 20:24:54 -07:00
parent ba64b3190b
commit f046b5c458

View File

@ -31,7 +31,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
new AutoFarmerCropType(Blocks.POTATOES, Items.POTATO, GROWTH_PATTERN.BASIC, Blocks.FARMLAND), new AutoFarmerCropType(Blocks.POTATOES, Items.POTATO, GROWTH_PATTERN.BASIC, Blocks.FARMLAND),
new AutoFarmerCropType(Blocks.CARROTS, Items.CARROT, GROWTH_PATTERN.BASIC, Blocks.FARMLAND), new AutoFarmerCropType(Blocks.CARROTS, Items.CARROT, GROWTH_PATTERN.BASIC, Blocks.FARMLAND),
new AutoFarmerCropType(Blocks.NETHER_WART, Items.NETHER_WART, GROWTH_PATTERN.BASIC, Blocks.SOUL_SAND), new AutoFarmerCropType(Blocks.NETHER_WART, Items.NETHER_WART, GROWTH_PATTERN.BASIC, Blocks.SOUL_SAND),
new AutoFarmerCropType(Blocks.SUGAR_CANE, null, GROWTH_PATTERN.LEAVE_BASE, null) new AutoFarmerCropType(Blocks.SUGAR_CANE, Items.SUGAR_CANE, GROWTH_PATTERN.LEAVE_BASE, null)
}; };
@ -199,7 +199,11 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
if (cropType.growth_pattern == GROWTH_PATTERN.LEAVE_BASE && block.isOf(cropType.crop_type) && if (cropType.growth_pattern == GROWTH_PATTERN.LEAVE_BASE && block.isOf(cropType.crop_type) &&
options.crops_enabled[i].get()) { options.crops_enabled[i].get()) {
if (options.seeds_enabled[i].get()) {
return isSecondBlock(client.world, pos, cropType.crop_type) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE; return isSecondBlock(client.world, pos, cropType.crop_type) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE;
} else {
return isBottomBlock(client.world, pos, cropType.crop_type) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE;
}
} }
if (cropType.seed_type != null && cropType.planted_on != null && block.isOf(cropType.planted_on) && if (cropType.seed_type != null && cropType.planted_on != null && block.isOf(cropType.planted_on) &&
@ -271,6 +275,10 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
!world.getBlockState(pos.down().down()).isOf(crop_type); !world.getBlockState(pos.down().down()).isOf(crop_type);
} }
private static boolean isBottomBlock(ClientWorld world, BlockPos pos, Block crop_type) {
return world.getBlockState(pos).isOf(crop_type) && !world.getBlockState(pos.down()).isOf(crop_type);
}
private static void sendStopPackets(MinecraftClient client) { private static void sendStopPackets(MinecraftClient client) {
if (client.world == null || client.player == null) if (client.world == null || client.player == null)
return; return;