Search in sources :

Example 6 with EntityDimensions

use of net.minecraft.entity.EntityDimensions 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);
}
Also used : EntityDimensions(net.minecraft.entity.EntityDimensions) Vec3i(net.minecraft.util.math.Vec3i) NearbyEntityListenerProvider(me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 7 with EntityDimensions

use of net.minecraft.entity.EntityDimensions in project lithium-fabric by CaffeineMC.

the class LookAtEntityGoalMixin method init.

@Inject(method = "<init>(Lnet/minecraft/entity/mob/MobEntity;Ljava/lang/Class;FFZ)V", at = @At("RETURN"))
private void init(MobEntity mob, Class<? extends LivingEntity> targetType, float range, float chance, boolean b, CallbackInfo ci) {
    EntityDimensions dimensions = this.mob.getType().getDimensions();
    double adjustedRange = dimensions.width * 0.5D + this.range + 2D;
    int horizontalRange = MathHelper.ceil(adjustedRange);
    this.tracker = new NearbyEntityTracker<>(targetType, mob, new Vec3i(horizontalRange, MathHelper.ceil(dimensions.height + 3 + 2), horizontalRange));
    ((NearbyEntityListenerProvider) mob).addListener(this.tracker);
}
Also used : EntityDimensions(net.minecraft.entity.EntityDimensions) Vec3i(net.minecraft.util.math.Vec3i) NearbyEntityListenerProvider(me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EntityDimensions (net.minecraft.entity.EntityDimensions)7 Identifier (net.minecraft.util.Identifier)5 NearbyEntityListenerProvider (me.jellysquid.mods.lithium.common.entity.tracker.nearby.NearbyEntityListenerProvider)2 Vec3d (net.minecraft.util.math.Vec3d)2 Vec3i (net.minecraft.util.math.Vec3i)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 ServerWorld (net.minecraft.server.world.ServerWorld)1 World (net.minecraft.world.World)1