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

43 lines
1 KiB
Java
Raw Normal View History

2019-03-23 20:49:34 +01:00
package com.minelittlepony.client.render;
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;
import com.minelittlepony.pony.IPony;
2019-11-23 18:28:42 +01:00
public class FrustrumCheck<T extends LivingEntity> extends Frustum {
private T entity;
2019-11-23 18:28:42 +01:00
private Frustum 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) {
2019-11-23 18:28:42 +01:00
super(new Matrix4f(), new Matrix4f());
renderer = render;
}
2019-11-23 18:28:42 +01:00
public Frustum withCamera(T entity, Frustum vanillaFrustrum) {
this.entity = entity;
vanilla = vanillaFrustrum;
return this;
}
@Override
2019-11-23 18:28:42 +01:00
public boolean isVisible(Box bounds) {
IPony pony = renderer.getPony(entity);
2019-06-27 19:28:21 +02:00
Box boundingBox = pony.getComputedBoundingBox(entity);
2019-11-23 18:28:42 +01:00
return vanilla.isVisible(boundingBox);
}
@Override
2019-11-23 18:28:42 +01:00
public void setPosition(double x, double y, double z) {
vanilla.setPosition(x, y, z);
}
}