package codechicken.lib.raytracer;

import net.minecraft.entity.Entity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;

public class ExtendedMOP extends MovingObjectPosition
{
    public Object data;
    
    public ExtendedMOP(Entity entity, Object data)
    {
        super(entity);
        setData(data);
    }
    
    public ExtendedMOP(int x, int y, int z, int side, Vec3 hit, Object data)
    {
        super(x, y, z, side, hit);
        setData(data);
    }
    
    public ExtendedMOP(MovingObjectPosition mop, Object data)
    {
        super(0, 0, 0, 0, mop.hitVec);
        typeOfHit = mop.typeOfHit;
        blockX = mop.blockX;
        blockY = mop.blockY;
        blockZ = mop.blockZ;
        sideHit = mop.sideHit;
        subHit = mop.subHit;
        setData(data);
    }

    public void setData(Object data)
    {
        if(data instanceof Integer)
            subHit = ((Integer) data).intValue();
        this.data = data;
    }
    
    @SuppressWarnings("unchecked")
    public static <T> T getData(MovingObjectPosition mop)
    {
        if(mop instanceof ExtendedMOP)
            return (T)((ExtendedMOP)mop).data;
        
        return (T)Integer.valueOf(mop.subHit);
    }
}

@@ -199,17 +199,52 @@
 Position
+ implements Comparable%3CExtendedMOP%3E
 %0A
-
 %7B%0A    pu
@@ -257,24 +257,48 @@
 bject data;%0A
+    public double dist;%0A
     %0A    pub
@@ -608,32 +608,45 @@
 mop, Object data
+, double dist
 )%0A    %7B%0A        
@@ -877,24 +877,50 @@
 Data(data);%0A
+        this.dist = dist;%0A
     %7D%0A%0A    p
@@ -1270,24 +1270,24 @@
 a;%0A        %0A
-
         retu
@@ -1327,10 +1327,141 @@
 ;%0A    %7D%0A
+    %0A    @Override%0A    public int compareTo(ExtendedMOP o)%0A    %7B%0A        return dist == o.dist ? 0 : dist %3C o.dist ? -1 : 1;%0A    %7D%0A
 %7D%0A

Extend MOP for RayTracer depth sorting.