2019-03-23 20:49:34 +01:00
|
|
|
package com.minelittlepony.client.render;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.client.render.VisibleRegion;
|
|
|
|
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
|
|
|
|
2019-03-23 20:58:50 +01:00
|
|
|
import com.minelittlepony.pony.IPony;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
public class FrustrumCheck<T extends LivingEntity> implements VisibleRegion {
|
2018-09-20 14:32:54 +02:00
|
|
|
|
|
|
|
private T entity;
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
private VisibleRegion vanilla;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
private final RenderPony<T, ?> renderer;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
public FrustrumCheck(RenderPony<T, ?> render) {
|
2018-09-20 14:32:54 +02:00
|
|
|
renderer = render;
|
|
|
|
}
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
public VisibleRegion withCamera(T entity, VisibleRegion vanillaFrustrum) {
|
2018-09-20 14:32:54 +02:00
|
|
|
this.entity = entity;
|
|
|
|
vanilla = vanillaFrustrum;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-06-27 19:28:21 +02:00
|
|
|
public boolean intersects(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-05-27 17:59:15 +02:00
|
|
|
return vanilla.intersects(boundingBox);
|
2018-09-20 14:32:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-27 17:59:15 +02:00
|
|
|
public void setOrigin(double x, double y, double z) {
|
|
|
|
vanilla.setOrigin(x, y, z);
|
2018-09-20 14:32:54 +02:00
|
|
|
}
|
|
|
|
}
|