use of org.spongepowered.common.event.tracking.phase.tick.EntityTickContext in project SpongeCommon by SpongePowered.
the class TrackingUtil method tickRidingEntity.
public static void tickRidingEntity(final net.minecraft.world.entity.Entity entity) {
checkArgument(entity instanceof Entity, "Entity %s is not an instance of SpongeAPI's Entity!", entity);
checkNotNull(entity, "Cannot capture on a null ticking entity!");
if (!((TrackableBridge) entity).bridge$shouldTick()) {
return;
}
final EntityTickContext tickContext = TickPhase.Tick.ENTITY.createPhaseContext(PhaseTracker.SERVER).source(entity);
try (final EntityTickContext context = tickContext;
final Timing entityTiming = ((TimingBridge) entity.getType()).bridge$timings()) {
entityTiming.startTiming();
if (entity instanceof CreatorTrackedBridge) {
((CreatorTrackedBridge) entity).tracker$getNotifierUUID().ifPresent(context::notifier);
((CreatorTrackedBridge) entity).tracker$getCreatorUUID().ifPresent(context::creator);
}
context.buildAndSwitch();
entity.rideTick();
if (ShouldFire.MOVE_ENTITY_EVENT) {
SpongeCommonEventFactory.callNaturalMoveEntityEvent(entity);
}
if (ShouldFire.ROTATE_ENTITY_EVENT) {
SpongeCommonEventFactory.callNaturalRotateEntityEvent(entity);
}
} catch (final Exception e) {
PhasePrinter.printExceptionFromPhase(PhaseTracker.getInstance().stack, e, tickContext);
}
}
Aggregations