2019-03-23 20:49:34 +01:00
|
|
|
package com.minelittlepony.client.render;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
|
|
|
import net.minecraft.client.renderer.culling.ICamera;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
|
2019-03-23 20:58:50 +01:00
|
|
|
import com.minelittlepony.pony.IPony;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
|
|
|
public class FrustrumCheck<T extends EntityLivingBase> implements ICamera {
|
|
|
|
|
|
|
|
private T entity;
|
|
|
|
|
|
|
|
private ICamera vanilla;
|
|
|
|
|
|
|
|
private final RenderPony<T> renderer;
|
|
|
|
|
|
|
|
public FrustrumCheck(RenderPony<T> render) {
|
|
|
|
renderer = render;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ICamera withCamera(T entity, ICamera vanillaFrustrum) {
|
|
|
|
this.entity = entity;
|
|
|
|
vanilla = vanillaFrustrum;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBoundingBoxInFrustum(AxisAlignedBB bounds) {
|
|
|
|
IPony pony = renderer.getPony(entity);
|
|
|
|
|
|
|
|
AxisAlignedBB boundingBox = pony.getComputedBoundingBox(entity);
|
|
|
|
|
|
|
|
return vanilla.isBoundingBoxInFrustum(boundingBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPosition(double x, double y, double z) {
|
|
|
|
vanilla.setPosition(x, y, z);
|
|
|
|
}
|
|
|
|
}
|