use of net.minecraft.block.BlockFarmland in project AgriCraft by AgriCraft.
the class TileEntitySprinkler method irrigate.
/**
* Depending on the block type either irrigates farmland or forces plant
* GROWTH (based on chance)
*/
private void irrigate(BlockPos pos, boolean farmlandOnly) {
IBlockState state = this.getWorld().getBlockState(pos);
Block block = state.getBlock();
if (block instanceof BlockFarmland && block.getMetaFromState(state) < 7) {
// irrigate farmland
int flag = counter == 0 ? 2 : 6;
worldObj.setBlockState(pos, block.getStateFromMeta(7), flag);
} else if (!farmlandOnly && ((block instanceof IPlantable) || (block instanceof IGrowable))) {
// X1 chance to force GROWTH tick on plant every Y1 ticks
if (counter == 0 && worldObj.rand.nextDouble() <= AgriCraftConfig.sprinklerGrowthChancePercent) {
block.updateTick(this.getWorld(), pos, state, worldObj.rand);
}
}
}
Aggregations