Search in sources :

Example 1 with NavigatingEntity

use of me.jellysquid.mods.lithium.common.entity.NavigatingEntity in project lithium-fabric by CaffeineMC.

the class ServerEntityHandlerMixin method startListeningOnEntityLoad.

@Redirect(method = "startTracking(Lnet/minecraft/entity/Entity;)V", at = @At(value = "INVOKE", target = "Ljava/util/Set;add(Ljava/lang/Object;)Z"))
private boolean startListeningOnEntityLoad(Set<MobEntity> set, Object mobEntityObj) {
    MobEntity mobEntity = (MobEntity) mobEntityObj;
    EntityNavigation navigation = mobEntity.getNavigation();
    ((NavigatingEntity) mobEntity).setRegisteredToWorld(navigation);
    if (navigation.getCurrentPath() != null) {
        ((ServerWorldExtended) this.outer).setNavigationActive(mobEntity);
    }
    return set.add(mobEntity);
}
Also used : EntityNavigation(net.minecraft.entity.ai.pathing.EntityNavigation) ServerWorldExtended(me.jellysquid.mods.lithium.common.world.ServerWorldExtended) NavigatingEntity(me.jellysquid.mods.lithium.common.entity.NavigatingEntity) MobEntity(net.minecraft.entity.mob.MobEntity) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 2 with NavigatingEntity

use of me.jellysquid.mods.lithium.common.entity.NavigatingEntity in project lithium-fabric by CaffeineMC.

the class ServerEntityHandlerMixin method stopListeningOnEntityUnload.

@Redirect(method = "stopTracking(Lnet/minecraft/entity/Entity;)V", at = @At(value = "INVOKE", target = "Ljava/util/Set;remove(Ljava/lang/Object;)Z"))
private boolean stopListeningOnEntityUnload(Set<MobEntity> set, Object mobEntityObj) {
    MobEntity mobEntity = (MobEntity) mobEntityObj;
    NavigatingEntity navigatingEntity = (NavigatingEntity) mobEntity;
    if (navigatingEntity.isRegisteredToWorld()) {
        EntityNavigation registeredNavigation = navigatingEntity.getRegisteredNavigation();
        if (registeredNavigation.getCurrentPath() != null) {
            ((ServerWorldExtended) this.outer).setNavigationInactive(mobEntity);
        }
        navigatingEntity.setRegisteredToWorld(null);
    }
    return set.remove(mobEntity);
}
Also used : EntityNavigation(net.minecraft.entity.ai.pathing.EntityNavigation) ServerWorldExtended(me.jellysquid.mods.lithium.common.world.ServerWorldExtended) NavigatingEntity(me.jellysquid.mods.lithium.common.entity.NavigatingEntity) MobEntity(net.minecraft.entity.mob.MobEntity) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

NavigatingEntity (me.jellysquid.mods.lithium.common.entity.NavigatingEntity)2 ServerWorldExtended (me.jellysquid.mods.lithium.common.world.ServerWorldExtended)2 EntityNavigation (net.minecraft.entity.ai.pathing.EntityNavigation)2 MobEntity (net.minecraft.entity.mob.MobEntity)2 Redirect (org.spongepowered.asm.mixin.injection.Redirect)2