private boolean canPollinate() { if (entity.cooldownPollination > 0) return false; IPollinatable pollinatable = Utils.getOrCreatePollinatable("", entity.worldObj, rest.posX, rest.posY, rest.posZ); if (pollinatable == null) return false; if (!entity .getButterfly() .getGenome() .getFlowerProvider() .isAcceptedPollinatable(entity.worldObj, pollinatable)) return false; if (entity.getPollen() != null && !pollinatable.canMateWith(entity.getPollen())) return false; return true; }
@Override public void updateTask() { if (canLayEgg && !hasLayedEgg) { IButterflyNursery tile = (IButterflyNursery) entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); if (tile.canNurse(entity.getButterfly())) { tile.setCaterpillar(entity.getButterfly().spawnCaterpillar(tile)); Proxies.log.finest( "A butterfly '%s' laid an egg at %s/%s/%s.", entity.getButterfly().getIdent(), rest.posX, rest.posY, rest.posZ); if (entity.getRNG().nextFloat() < 1.0f / entity.getButterfly().getGenome().getFertility()) entity.setHealth(0); } hasLayedEgg = true; entity.cooldownEgg = EntityButterfly.COOLDOWNS; } if (canPollinate && !hasPollinated) { IPollinatable pollinatable = (IPollinatable) entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); if (entity.getPollen() == null) { entity.setPollen(pollinatable.getPollen()); // Proxies.log.finest("A butterfly '%s' grabbed a pollen '%s' at %s/%s/%s.", // entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, // rest.posZ); } else if (pollinatable.canMateWith(entity.getPollen())) { pollinatable.mateWith(entity.getPollen()); // Proxies.log.finest("A butterfly '%s' unloaded pollen '%s' at %s/%s/%s.", // entity.getButterfly().getIdent(), entity.getPollen().getIdent(), rest.posX, rest.posY, // rest.posZ); entity.setPollen(null); } hasPollinated = true; entity.cooldownPollination = EntityButterfly.COOLDOWNS; } }