use of org.bukkit.event.entity.EntityBreedEvent in project LaBoulangerieMmo by LaBoulangerie.
the class AnimalTwins method trigger.
@Override
public void trigger(Event baseEvent, int level) {
EntityBreedEvent event = (EntityBreedEvent) baseEvent;
Entity animal = event.getEntity();
int max_number = 100;
int min_number = 1;
Random random_chance = new Random();
int find_nearest_int = min_number + random_chance.nextInt(max_number);
if (level >= 60) {
animal.getWorld().spawnEntity(animal.getLocation(), animal.getType());
} else if (level >= 40 && find_nearest_int <= 40) {
animal.getWorld().spawnEntity(animal.getLocation(), animal.getType());
} else if (find_nearest_int <= 10) {
animal.getWorld().spawnEntity(animal.getLocation(), animal.getType());
}
}
use of org.bukkit.event.entity.EntityBreedEvent in project Arclight by IzzelAliz.
the class FoxEntity_MateGoalMixin method spawnBaby.
/**
* @author IzzekAkuz
* @reason
*/
@Overwrite
protected void spawnBaby() {
FoxEntity foxentity = (FoxEntity) this.animal.createChild(this.targetMate);
if (foxentity != null) {
ServerPlayerEntity serverplayerentity = this.animal.getLoveCause();
ServerPlayerEntity serverplayerentity1 = this.targetMate.getLoveCause();
ServerPlayerEntity serverplayerentity2 = serverplayerentity;
if (serverplayerentity != null) {
((FoxEntityBridge) foxentity).bridge$addTrustedUUID(serverplayerentity.getUniqueID());
} else {
serverplayerentity2 = serverplayerentity1;
}
if (serverplayerentity1 != null && serverplayerentity != serverplayerentity1) {
((FoxEntityBridge) foxentity).bridge$addTrustedUUID(serverplayerentity1.getUniqueID());
}
int experience = this.animal.getRNG().nextInt(7) + 1;
final EntityBreedEvent entityBreedEvent = CraftEventFactory.callEntityBreedEvent(foxentity, this.animal, this.targetMate, serverplayerentity, ((AnimalEntityBridge) this.animal).bridge$getBreedItem(), experience);
if (entityBreedEvent.isCancelled()) {
return;
}
experience = entityBreedEvent.getExperience();
if (serverplayerentity2 != null) {
serverplayerentity2.addStat(Stats.ANIMALS_BRED);
CriteriaTriggers.BRED_ANIMALS.trigger(serverplayerentity2, this.animal, this.targetMate, foxentity);
}
int i = 6000;
this.animal.setGrowingAge(6000);
this.targetMate.setGrowingAge(6000);
this.animal.resetInLove();
this.targetMate.resetInLove();
foxentity.setGrowingAge(-24000);
foxentity.setLocationAndAngles(this.animal.posX, this.animal.posY, this.animal.posZ, 0.0F, 0.0F);
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING);
this.world.addEntity(foxentity);
this.world.setEntityState(this.animal, (byte) 18);
if (this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
if (experience > 0) {
this.world.addEntity(new ExperienceOrbEntity(this.world, this.animal.posX, this.animal.posY, this.animal.posZ, experience));
}
}
}
}
use of org.bukkit.event.entity.EntityBreedEvent in project Arclight by IzzelAliz.
the class BreedGoalMixin method arclight$persist.
@Inject(method = "spawnBaby", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/entity/passive/AnimalEntity;getLoveCause()Lnet/minecraft/entity/player/ServerPlayerEntity;"))
public void arclight$persist(CallbackInfo ci, AgeableEntity ageableEntity) {
if (ageableEntity instanceof TameableEntity && ((TameableEntity) ageableEntity).isTamed()) {
((LivingEntityBridge) ageableEntity).bridge$setPersist(true);
}
ServerPlayerEntity playerEntity = this.animal.getLoveCause();
if (playerEntity == null && this.targetMate.getLoveCause() != null) {
playerEntity = this.targetMate.getLoveCause();
}
arclight$exp = this.animal.getRNG().nextInt(7) + 1;
EntityBreedEvent event = CraftEventFactory.callEntityBreedEvent(ageableEntity, this.animal, this.targetMate, playerEntity, ((AnimalEntityBridge) this.animal).bridge$getBreedItem(), arclight$exp);
if (event.isCancelled()) {
ci.cancel();
return;
}
arclight$exp = event.getExperience();
}
Aggregations