2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-01-31 18:11:50 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
|
|
|
|
|
|
|
public class BusCollisionHelper implements IPartCollsionHelper
|
|
|
|
{
|
|
|
|
|
|
|
|
final List<AxisAlignedBB> boxes;
|
|
|
|
|
|
|
|
final private ForgeDirection x;
|
|
|
|
final private ForgeDirection y;
|
|
|
|
final private ForgeDirection z;
|
|
|
|
|
2014-01-31 18:11:50 +01:00
|
|
|
final private Entity entity;
|
|
|
|
final private boolean isVisual;
|
|
|
|
|
|
|
|
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection x, ForgeDirection y, ForgeDirection z, Entity e, boolean visual) {
|
2013-12-27 23:59:59 +01:00
|
|
|
this.boxes = boxes;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
2014-01-31 18:11:50 +01:00
|
|
|
entity = e;
|
|
|
|
isVisual = visual;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-01-31 18:11:50 +01:00
|
|
|
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection s, Entity e, boolean visual) {
|
2013-12-27 23:59:59 +01:00
|
|
|
this.boxes = boxes;
|
2014-01-31 18:11:50 +01:00
|
|
|
entity = e;
|
|
|
|
isVisual = visual;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
switch (s)
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
x = ForgeDirection.EAST;
|
|
|
|
y = ForgeDirection.NORTH;
|
|
|
|
z = ForgeDirection.DOWN;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
x = ForgeDirection.EAST;
|
|
|
|
y = ForgeDirection.SOUTH;
|
|
|
|
z = ForgeDirection.UP;
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
x = ForgeDirection.SOUTH;
|
|
|
|
y = ForgeDirection.UP;
|
|
|
|
z = ForgeDirection.EAST;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
x = ForgeDirection.NORTH;
|
|
|
|
y = ForgeDirection.UP;
|
|
|
|
z = ForgeDirection.WEST;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
x = ForgeDirection.WEST;
|
|
|
|
y = ForgeDirection.UP;
|
|
|
|
z = ForgeDirection.NORTH;
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
x = ForgeDirection.EAST;
|
|
|
|
y = ForgeDirection.UP;
|
|
|
|
z = ForgeDirection.SOUTH;
|
|
|
|
break;
|
|
|
|
case UNKNOWN:
|
|
|
|
default:
|
|
|
|
x = ForgeDirection.EAST;
|
|
|
|
y = ForgeDirection.UP;
|
|
|
|
z = ForgeDirection.SOUTH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-31 18:11:50 +01:00
|
|
|
@Override
|
|
|
|
public boolean isBBCollision()
|
|
|
|
{
|
|
|
|
return !isVisual;
|
|
|
|
}
|
|
|
|
|
2014-02-01 06:37:27 +01:00
|
|
|
/**
|
|
|
|
* pretty much useless...
|
|
|
|
*/
|
|
|
|
public Entity getEntity()
|
|
|
|
{
|
|
|
|
return entity;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
|
|
|
|
{
|
|
|
|
minX /= 16.0;
|
|
|
|
minY /= 16.0;
|
|
|
|
minZ /= 16.0;
|
|
|
|
maxX /= 16.0;
|
|
|
|
maxY /= 16.0;
|
|
|
|
maxZ /= 16.0;
|
|
|
|
|
|
|
|
double aX = minX * x.offsetX + minY * y.offsetX + minZ * z.offsetX;
|
|
|
|
double aY = minX * x.offsetY + minY * y.offsetY + minZ * z.offsetY;
|
|
|
|
double aZ = minX * x.offsetZ + minY * y.offsetZ + minZ * z.offsetZ;
|
|
|
|
|
|
|
|
double bX = maxX * x.offsetX + maxY * y.offsetX + maxZ * z.offsetX;
|
|
|
|
double bY = maxX * x.offsetY + maxY * y.offsetY + maxZ * z.offsetY;
|
|
|
|
double bZ = maxX * x.offsetZ + maxY * y.offsetZ + maxZ * z.offsetZ;
|
|
|
|
|
|
|
|
if ( x.offsetX + y.offsetX + z.offsetX < 0 )
|
|
|
|
{
|
|
|
|
aX += 1;
|
|
|
|
bX += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( x.offsetY + y.offsetY + z.offsetY < 0 )
|
|
|
|
{
|
|
|
|
aY += 1;
|
|
|
|
bY += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( x.offsetZ + y.offsetZ + z.offsetZ < 0 )
|
|
|
|
{
|
|
|
|
aZ += 1;
|
|
|
|
bZ += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
minX = Math.min( aX, bX );
|
|
|
|
minY = Math.min( aY, bY );
|
|
|
|
minZ = Math.min( aZ, bZ );
|
|
|
|
maxX = Math.max( aX, bX );
|
|
|
|
maxY = Math.max( aY, bY );
|
|
|
|
maxZ = Math.max( aZ, bZ );
|
|
|
|
|
|
|
|
boxes.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldX()
|
|
|
|
{
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldY()
|
|
|
|
{
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldZ()
|
|
|
|
{
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|