Fixed farmer not planting potatoes / carrots. Fixes #1464

This commit is contained in:
Flanks255 2024-11-30 14:53:25 -06:00
parent e9b5c7f813
commit b23ba8f0b8
3 changed files with 13 additions and 2 deletions

View file

@ -11,6 +11,10 @@
* Fix Black Quartz wall recipe conflicts * Fix Black Quartz wall recipe conflicts
* Fix output of Wall, Stair and Slab recipes * Fix output of Wall, Stair and Slab recipes
* Add stonecutter recipes for the walls/stairs and slabs * Add stonecutter recipes for the walls/stairs and slabs
* Fixed Farmer being unable to plant potatoes / carrots.
* Possible fix for very rare stack overflow.
* Reinforced fix for drills breaking in certain circumstances.
* Fix for drill not dropping block contents for certain mods.
# 1.3.10+mc1.21.1 # 1.3.10+mc1.21.1
* Fixed Fluid placer not being harvestable. * Fixed Fluid placer not being harvestable.

View file

@ -78,8 +78,8 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
farmer.extractEnergy(use); farmer.extractEnergy(use);
return FarmerResult.SUCCESS; return FarmerResult.SUCCESS;
} else { } else {
if (seed.is(Tags.Items.SEEDS) && seed.getItem() instanceof BlockItem blockItem) { if (isPlantable(seed)) {
if (defaultPlant(world, pos, blockItem.getBlock().defaultBlockState(), farmer, use)) { if (defaultPlant(world, pos, ((BlockItem)seed.getItem()).getBlock().defaultBlockState(), farmer, use)) {
return FarmerResult.SUCCESS; return FarmerResult.SUCCESS;
} }
} }
@ -88,6 +88,12 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
return FarmerResult.FAIL; return FarmerResult.FAIL;
} }
private boolean isPlantable(ItemStack seed) {
if (seed.is(Tags.Items.SEEDS) && seed.getItem() instanceof BlockItem) {
return true;
} else return seed.getItem() instanceof BlockItem blockItem && blockItem.getBlock() instanceof CropBlock;
}
@Override @Override
public FarmerResult tryHarvestPlant(ServerLevel world, BlockPos pos, IFarmer farmer) { public FarmerResult tryHarvestPlant(ServerLevel world, BlockPos pos, IFarmer farmer) {
int use = 250; int use = 250;

View file

@ -60,6 +60,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
public TileEntityFarmer(BlockPos pos, BlockState state) { public TileEntityFarmer(BlockPos pos, BlockState state) {
super(ActuallyBlocks.FARMER.getTileEntityType(), pos, state, 12); super(ActuallyBlocks.FARMER.getTileEntityType(), pos, state, 12);
area = CommonConfig.Machines.FARMER_AREA.get();
} }
@Override @Override