use of org.spongepowered.api.entity.living.animal.horse.HorseLike in project SpongeCommon by SpongePowered.
the class RunAroundLikeCrazyGoalMixin method tick.
// @formatter:on
/**
* @author rexbut - December 16th, 2016
* @author i509VCB - February 18th, 2020 - 1.14.4
*
* @reason - adjusted to support {@link DismountTypes}
*/
@Overwrite
public void tick() {
if (!this.horse.isTamed() && this.horse.getRandom().nextInt(50) == 0) {
Entity entity = this.horse.getPassengers().get(0);
if (entity == null) {
return;
}
if (entity instanceof Player) {
int i = this.horse.getTemper();
int j = this.horse.getMaxTemper();
if (j > 0 && this.horse.getRandom().nextInt(j) < i) {
// Sponge start - Fire Tame Entity event
try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) {
frame.pushCause(entity);
if (SpongeCommon.post(SpongeEventFactory.createTameEntityEvent(frame.currentCause(), (HorseLike) this.horse))) {
return;
}
}
// Sponge end
this.horse.tameWithName((Player) entity);
return;
}
this.horse.modifyTemper(5);
}
// this.horseHost.ejectPassengers(); // Vanilla
if (((EntityBridge) this.horse).bridge$removePassengers(DismountTypes.DERAIL.get())) {
// Sponge end
this.horse.makeMad();
this.horse.level.broadcastEntityEvent(this.horse, (byte) 6);
}
}
}
Aggregations