Search in sources :

Example 1 with AgeableMob

use of net.minecraft.world.entity.AgeableMob in project Tropicraft by Tropicraft.

the class EntityAIKoaMate method giveBirth.

/*private boolean canTownHandleMoreVillagers112()
    {
        TownKoaVillage village = villagerObj.getVillage();

        if (village == null) {
            if (villagerObj.findAndSetTownID(true)) {
                village = villagerObj.getVillage();

                //just in case
                if (village == null) return false;
            } else {
                return false;
            }
        }

        return village.getPopulationSize() < village.getMaxPopulationSize();
    }*/
// TODO: 1.14 readd
private void giveBirth() {
    AgeableMob entityvillager = this.villagerObj.getBreedOffspring((ServerLevel) world, this.mate);
    this.mate.setAge(6000);
    this.villagerObj.setAge(6000);
    this.mate.setIsWillingToMate(false);
    this.villagerObj.setIsWillingToMate(false);
    // final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(villagerObj, mate, entityvillager);
    // if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event) || event.getChild() == null) { return; }
    // entityvillager = event.getChild();
    entityvillager.setAge(-24000);
    entityvillager.moveTo(villagerObj.getX(), villagerObj.getY(), villagerObj.getZ(), 0.0F, 0.0F);
    if (entityvillager instanceof EntityKoaBase) {
        ((EntityKoaBase) entityvillager).setVillageAndDimID(villagerObj.getVillageID(), villagerObj.getVillageDimension());
        entityvillager.restrictTo(villagerObj.getRestrictCenter(), EntityKoaBase.MAX_HOME_DISTANCE);
        // TODO: 1.14 readd
        /*TownKoaVillage village = villagerObj.getVillage();
            if (village != null) {
                ((EntityKoaBase) entityvillager).postSpawnGenderFix();

                village.addEntity(entityvillager);
            }*/
        ((EntityKoaBase) entityvillager).updateUniqueEntityAI();
        entityvillager.level.playSound(null, entityvillager.blockPosition(), SoundEvents.CHICKEN_EGG, SoundSource.AMBIENT, 1, 1);
    }
    this.world.addFreshEntity(entityvillager);
    this.world.broadcastEntityEvent(entityvillager, (byte) 12);
}
Also used : EntityKoaBase(net.tropicraft.core.common.entity.passive.EntityKoaBase) AgeableMob(net.minecraft.world.entity.AgeableMob)

Aggregations

AgeableMob (net.minecraft.world.entity.AgeableMob)1 EntityKoaBase (net.tropicraft.core.common.entity.passive.EntityKoaBase)1