Search in sources :

Example 1 with ServerWorldExtended

use of me.jellysquid.mods.lithium.common.world.ServerWorldExtended in project lithium-fabric by CaffeineMC.

the class MobEntityMixin method updateNavigationRegistration.

@Override
public void updateNavigationRegistration() {
    if (this.isRegisteredToWorld()) {
        EntityNavigation navigation = this.getNavigation();
        if (this.registeredNavigation != navigation) {
            ((ServerWorldExtended) this.world).setNavigationInactive((MobEntity) (Object) this);
            this.registeredNavigation = navigation;
            if (navigation.getCurrentPath() != null) {
                ((ServerWorldExtended) this.world).setNavigationActive((MobEntity) (Object) this);
            }
        }
    }
}
Also used : EntityNavigation(net.minecraft.entity.ai.pathing.EntityNavigation) ServerWorldExtended(me.jellysquid.mods.lithium.common.world.ServerWorldExtended)

Example 2 with ServerWorldExtended

use of me.jellysquid.mods.lithium.common.world.ServerWorldExtended 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 3 with ServerWorldExtended

use of me.jellysquid.mods.lithium.common.world.ServerWorldExtended 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

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