use of com.minecolonies.coremod.network.messages.client.CompostParticleMessage in project minecolonies by Minecolonies.
the class EntityAIWorkFarmer method shouldHarvest.
/**
* Checks if the crop should be harvested.
*
* @param position the position to check.
* @return true if should be harvested.
*/
private boolean shouldHarvest(@NotNull final BlockPos position) {
BlockState state = world.getBlockState(position.above());
Block block = state.getBlock();
if (block == Blocks.PUMPKIN || block == Blocks.MELON) {
return true;
}
if (isCrop(block)) {
@NotNull CropsBlock crop = (CropsBlock) block;
if (crop.isMaxAge(state)) {
return true;
}
final int amountOfCompostInInv = InventoryUtils.getItemCountInItemHandler(worker.getInventoryCitizen(), this::isCompost);
if (amountOfCompostInInv == 0) {
return false;
}
if (InventoryUtils.shrinkItemCountInItemHandler(worker.getInventoryCitizen(), this::isCompost)) {
Network.getNetwork().sendToPosition(new CompostParticleMessage(position.above()), new PacketDistributor.TargetPoint(position.getX(), position.getY(), position.getZ(), BLOCK_BREAK_SOUND_RANGE, world.dimension()));
crop.growCrops(world, position.above(), state);
state = world.getBlockState(position.above());
block = state.getBlock();
if (isCrop(block)) {
crop = (CropsBlock) block;
} else {
return false;
}
}
return crop.isMaxAge(state);
}
return false;
}
use of com.minecolonies.coremod.network.messages.client.CompostParticleMessage in project minecolonies by ldtteam.
the class EntityAIWorkFarmer method shouldHarvest.
/**
* Checks if the crop should be harvested.
*
* @param position the position to check.
* @return true if should be harvested.
*/
private boolean shouldHarvest(@NotNull final BlockPos position) {
BlockState state = world.getBlockState(position.above());
Block block = state.getBlock();
if (block == Blocks.PUMPKIN || block == Blocks.MELON) {
return true;
}
if (isCrop(block)) {
@NotNull CropsBlock crop = (CropsBlock) block;
if (crop.isMaxAge(state)) {
return true;
}
final int amountOfCompostInInv = InventoryUtils.getItemCountInItemHandler(worker.getInventoryCitizen(), this::isCompost);
if (amountOfCompostInInv == 0) {
return false;
}
if (InventoryUtils.shrinkItemCountInItemHandler(worker.getInventoryCitizen(), this::isCompost)) {
Network.getNetwork().sendToPosition(new CompostParticleMessage(position.above()), new PacketDistributor.TargetPoint(position.getX(), position.getY(), position.getZ(), BLOCK_BREAK_SOUND_RANGE, world.dimension()));
crop.growCrops(world, position.above(), state);
state = world.getBlockState(position.above());
block = state.getBlock();
if (isCrop(block)) {
crop = (CropsBlock) block;
} else {
return false;
}
}
return crop.isMaxAge(state);
}
return false;
}
Aggregations