MineLittlePony/src/main/java/com/minelittlepony/client/render/FrustrumCheck.java

41 lines
994 B
Java
Raw Normal View History

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