2019-03-23 20:49:34 +01:00
|
|
|
package com.minelittlepony.client.render;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-11-23 18:28:42 +01:00
|
|
|
import net.minecraft.client.render.Frustum;
|
|
|
|
import net.minecraft.client.util.math.Matrix4f;
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
2019-06-27 19:28:21 +02:00
|
|
|
import net.minecraft.util.math.Box;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2020-04-03 23:54:12 +02:00
|
|
|
import com.minelittlepony.api.pony.IPony;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-11-23 18:28:42 +01:00
|
|
|
public class FrustrumCheck<T extends LivingEntity> extends Frustum {
|
2018-09-20 14:32:54 +02:00
|
|
|
|
|
|
|
private T entity;
|
|
|
|
|
2019-11-23 18:28:42 +01:00
|
|
|
private Frustum vanilla;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-11-29 16:26:19 +01:00
|
|
|
private final EquineRenderManager<T, ?> renderer;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-11-29 16:26:19 +01:00
|
|
|
public FrustrumCheck(EquineRenderManager<T, ?> render) {
|
2019-11-23 18:28:42 +01:00
|
|
|
super(new Matrix4f(), new Matrix4f());
|
2018-09-20 14:32:54 +02:00
|
|
|
renderer = render;
|
|
|
|
}
|
|
|
|
|
2019-11-23 18:28:42 +01:00
|
|
|
public Frustum withCamera(T entity, Frustum vanillaFrustrum) {
|
2018-09-20 14:32:54 +02:00
|
|
|
this.entity = entity;
|
|
|
|
vanilla = vanillaFrustrum;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-11-23 18:28:42 +01:00
|
|
|
public boolean isVisible(Box bounds) {
|
2018-09-20 14:32:54 +02:00
|
|
|
IPony pony = renderer.getPony(entity);
|
|
|
|
|
2019-06-27 19:28:21 +02:00
|
|
|
Box boundingBox = pony.getComputedBoundingBox(entity);
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-11-23 18:28:42 +01:00
|
|
|
return vanilla.isVisible(boundingBox);
|
2018-09-20 14:32:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-11-23 18:28:42 +01:00
|
|
|
public void setPosition(double x, double y, double z) {
|
|
|
|
vanilla.setPosition(x, y, z);
|
2018-09-20 14:32:54 +02:00
|
|
|
}
|
|
|
|
}
|