MineLittlePony/src/main/java/com/minelittlepony/client/PonyBounds.java

29 lines
1 KiB
Java
Raw Normal View History

package com.minelittlepony.client;
import com.minelittlepony.api.pony.Pony;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class PonyBounds {
private static Vec3d getBaseRidingOffset(LivingEntity entity) {
2024-06-04 23:43:55 +01:00
float delta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
return new Vec3d(
MathHelper.lerp(delta, entity.prevX, entity.getX()),
MathHelper.lerp(delta, entity.prevY, entity.getY()),
MathHelper.lerp(delta, entity.prevZ, entity.getZ())
);
}
public static Box getBoundingBox(Pony pony, LivingEntity entity) {
final float scale = pony.size().scaleFactor();
final float width = entity.getWidth() * scale;
final float height = entity.getHeight() * scale;
return new Box(-width, 0, -width, width, height, width).offset(getBaseRidingOffset(entity));
}
}