use of me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider in project lithium-fabric by CaffeineMC.
the class ServerEntityManagerListenerMixin method onAddEntity.
@Inject(method = "updateEntityPosition()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/EntityTrackingSection;add(Lnet/minecraft/world/entity/EntityLike;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
private void onAddEntity(CallbackInfo ci, BlockPos blockPos, long newPos, EntityTrackingStatus entityTrackingStatus, EntityTrackingSection<T> entityTrackingSection) {
NearbyEntityListenerMulti listener = ((NearbyEntityListenerProvider) this.entity).getListener();
if (listener != null) {
// noinspection unchecked
listener.forEachChunkInRangeChange(((ServerEntityManagerAccessor<T>) this.manager).getCache(), ChunkSectionPos.from(this.sectionPos), ChunkSectionPos.from(newPos));
}
this.notifyMovementListeners();
}
use of me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider in project lithium-fabric by CaffeineMC.
the class ServerEntityManagerListenerMixin method onRemoveEntity.
@Inject(method = "remove(Lnet/minecraft/entity/Entity$RemovalReason;)V", at = @At(value = "HEAD"))
private void onRemoveEntity(Entity.RemovalReason reason, CallbackInfo ci) {
NearbyEntityListenerMulti listener = ((NearbyEntityListenerProvider) this.entity).getListener();
if (listener != null) {
// noinspection unchecked
listener.forEachChunkInRangeChange(((ServerEntityManagerAccessor<T>) this.manager).getCache(), ChunkSectionPos.from(this.sectionPos), null);
}
this.notifyMovementListeners();
}
use of me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider in project roadrunner by MaxNeedsSnacks.
the class EntityTrackerEngine method onEntityAdded.
/**
* Called when an entity is added to the world.
*/
public void onEntityAdded(int x, int y, int z, LivingEntity entity) {
if (this.addEntity(x, y, z, entity)) {
if (entity instanceof NearbyEntityListenerProvider) {
NearbyEntityListenerMulti listener = ((NearbyEntityListenerProvider) entity).getListener();
this.addListener(x, y, z, listener);
listener.setTrackingEngine(this);
}
}
}
use of me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider in project roadrunner by MaxNeedsSnacks.
the class EntityTrackerEngine method onEntityRemoved.
/**
* Called when an entity is removed from the world.
*/
public void onEntityRemoved(int x, int y, int z, LivingEntity entity) {
if (this.removeEntity(x, y, z, entity)) {
if (entity instanceof NearbyEntityListenerProvider) {
NearbyEntityListenerMulti listener = ((NearbyEntityListenerProvider) entity).getListener();
this.removeListener(listener);
listener.clearTrackingEngine();
}
}
}
use of me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider in project lithium-fabric by CaffeineMC.
the class FleeEntityGoalMixin method init.
@Inject(method = "<init>(Lnet/minecraft/entity/mob/PathAwareEntity;Ljava/lang/Class;Ljava/util/function/Predicate;FDDLjava/util/function/Predicate;)V", at = @At("RETURN"))
private void init(PathAwareEntity mob, Class<T> fleeFromType, Predicate<LivingEntity> predicate, float distance, double slowSpeed, double fastSpeed, Predicate<LivingEntity> predicate2, CallbackInfo ci) {
EntityDimensions dimensions = this.mob.getType().getDimensions();
double adjustedRange = dimensions.width * 0.5D + this.fleeDistance + 2D;
int horizontalRange = MathHelper.ceil(adjustedRange);
this.tracker = new NearbyEntityTracker<>(fleeFromType, mob, new Vec3i(horizontalRange, MathHelper.ceil(dimensions.height + 3 + 2), horizontalRange));
((NearbyEntityListenerProvider) mob).addListener(this.tracker);
}
Aggregations