2022-12-08 20:53:30 +00:00
|
|
|
package com.minelittlepony.client;
|
|
|
|
|
2023-09-25 21:07:09 +01:00
|
|
|
import com.minelittlepony.api.pony.Pony;
|
2022-12-08 20:53:30 +00:00
|
|
|
|
|
|
|
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);
|
2022-12-08 20:53:30 +00:00
|
|
|
return new Vec3d(
|
|
|
|
MathHelper.lerp(delta, entity.prevX, entity.getX()),
|
2024-04-30 17:04:59 +01:00
|
|
|
MathHelper.lerp(delta, entity.prevY, entity.getY()),
|
2022-12-08 20:53:30 +00:00
|
|
|
MathHelper.lerp(delta, entity.prevZ, entity.getZ())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-09-25 21:07:09 +01:00
|
|
|
public static Box getBoundingBox(Pony pony, LivingEntity entity) {
|
2024-04-30 17:04:59 +01:00
|
|
|
final float scale = pony.size().scaleFactor();
|
2022-12-08 20:53:30 +00:00
|
|
|
final float width = entity.getWidth() * scale;
|
|
|
|
final float height = entity.getHeight() * scale;
|
|
|
|
|
2024-04-30 17:04:59 +01:00
|
|
|
return new Box(-width, 0, -width, width, height, width).offset(getBaseRidingOffset(entity));
|
2022-12-08 20:53:30 +00:00
|
|
|
}
|
|
|
|
}
|