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;
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;
2020-04-16 23:35:28 +02:00
import net.minecraft.util.math.Matrix4f;
2020-04-03 23:54:12 +02:00
import com.minelittlepony.api.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-11-29 16:26:19 +01:00
private final EquineRenderManager<T, ?> renderer;
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());
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);
}
}