use of net.minecraft.util.math.Vec3d in project ImmersiveEngineering by BluSunrize.
the class TileEntityConnectorStructural method getConnectionOffset.
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = facing.getOpposite();
double conRadius = .03125;
return new Vec3d(.5 + side.getFrontOffsetX() * (-.125 - conRadius), .5 + side.getFrontOffsetY() * (-.125 - conRadius), .5 + side.getFrontOffsetZ() * (-.125 - conRadius));
}
use of net.minecraft.util.math.Vec3d in project ImmersiveEngineering by BluSunrize.
the class TileEntityFloodlight method updateFakeLights.
public void updateFakeLights(boolean deleteOld, boolean genNew) {
Iterator<BlockPos> it = this.fakeLights.iterator();
ArrayList<BlockPos> tempRemove = new ArrayList<BlockPos>();
while (it.hasNext()) {
BlockPos cc = it.next();
TileEntity te = worldObj.getTileEntity(cc);
if (te instanceof TileEntityFakeLight) {
if (deleteOld)
tempRemove.add(cc);
} else
it.remove();
}
if (genNew) {
float angle = (float) (facing == EnumFacing.NORTH ? 180 : facing == EnumFacing.EAST ? 90 : facing == EnumFacing.WEST ? -90 : 0);
float yRotation = rotY;
double angleX = Math.toRadians(rotX);
Vec3d[] rays = { /*Straight*/
new Vec3d(0, 0, 1), /*U,D,L,R*/
new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), /*Intermediate*/
new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), /*Diagonal*/
new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1) };
Matrix4 mat = new Matrix4();
if (side == EnumFacing.DOWN)
mat.scale(1, -1, 1);
else if (side != EnumFacing.UP) {
angle = facing == EnumFacing.DOWN ? 180 : facing == EnumFacing.NORTH ? -90 : facing == EnumFacing.SOUTH ? 90 : angle;
if (side.getAxis() == Axis.X) {
mat.rotate(Math.PI / 2, -1, 0, 0);
mat.rotate(Math.PI / 2, 0, 0, -side.getAxisDirection().getOffset());
} else {
mat.rotate(Math.PI / 2, -1, 0, 0);
if (//I dunno why south is giving me so much trouble, but this works, so who cares
side == EnumFacing.SOUTH) {
mat.rotate(Math.PI, 0, 0, 1);
if (facing.getAxis() == Axis.X)
angle = -angle;
}
}
}
double angleY = Math.toRadians(angle + yRotation);
mat.rotate(angleY, 0, 1, 0);
mat.rotate(-angleX, 1, 0, 0);
rays[0] = mat.apply(rays[0]);
mat.rotate(Math.PI / 8, 0, 1, 0);
rays[1] = mat.apply(rays[1]);
mat.rotate(-Math.PI / 16, 0, 1, 0);
rays[5] = mat.apply(rays[5]);
mat.rotate(-Math.PI / 8, 0, 1, 0);
rays[6] = mat.apply(rays[6]);
mat.rotate(-Math.PI / 16, 0, 1, 0);
rays[2] = mat.apply(rays[2]);
mat.rotate(Math.PI / 8, 0, 1, 0);
mat.rotate(Math.PI / 8, 1, 0, 0);
rays[3] = mat.apply(rays[3]);
mat.rotate(-Math.PI / 16, 1, 0, 0);
rays[7] = mat.apply(rays[7]);
mat.rotate(-Math.PI / 8, 1, 0, 0);
rays[8] = mat.apply(rays[8]);
mat.rotate(-Math.PI / 16, 1, 0, 0);
rays[4] = mat.apply(rays[4]);
mat.rotate(Math.PI / 8, 1, 0, 0);
mat.rotate(Math.PI / 16, 1, 0, 0);
mat.rotate(Math.PI / 16, 0, 1, 0);
rays[9] = mat.apply(rays[9]);
mat.rotate(-Math.PI / 8, 0, 1, 0);
rays[10] = mat.apply(rays[10]);
mat.rotate(-Math.PI / 8, 1, 0, 0);
rays[11] = mat.apply(rays[11]);
mat.rotate(Math.PI / 8, 0, 1, 0);
rays[12] = mat.apply(rays[12]);
for (int ray = 0; ray < rays.length; ray++) {
int offset = ray == 0 ? 0 : ray < 4 ? 3 : 1;
placeLightAlongVector(rays[ray], offset, tempRemove);
}
}
this.lightsToBeRemoved.addAll(tempRemove);
}
use of net.minecraft.util.math.Vec3d in project ImmersiveEngineering by BluSunrize.
the class TileEntityFluidPipe method hammerUseSide.
@Override
public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) {
if (worldObj.isRemote)
return true;
EnumFacing fd = side;
List<AxisAlignedBB> boxes = this.getAdvancedSelectionBounds();
for (AxisAlignedBB box : boxes) if (box instanceof AdvancedAABB) {
if (box.expand(.002, .002, .002).isVecInside(new Vec3d(getPos().getX() + hitX, getPos().getY() + hitY, getPos().getZ() + hitZ)))
if (box instanceof AdvancedAABB && ((AdvancedAABB) box).fd != null)
fd = ((AdvancedAABB) box).fd;
}
if (fd != null) {
toggleSide(fd.ordinal());
this.markContainingBlockForUpdate(null);
TileEntityFluidPipe.indirectConnections.clear();
return true;
}
return false;
}
use of net.minecraft.util.math.Vec3d in project ImmersiveEngineering by BluSunrize.
the class TileEntityEnergyMeter method getRaytraceOffset.
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
int xDif = ((TileEntity) link).getPos().getX() - getPos().getX();
int zDif = ((TileEntity) link).getPos().getZ() - getPos().getZ();
if (facing.getAxis() == Axis.X)
return new Vec3d(.5, .4375, zDif > 0 ? .8125 : .1875);
else
return new Vec3d(xDif > 0 ? .8125 : .1875, .4375, .5);
}
use of net.minecraft.util.math.Vec3d in project ImmersiveEngineering by BluSunrize.
the class TileEntityEnergyMeter method getConnectionOffset.
@Override
public Vec3d getConnectionOffset(Connection con) {
int xDif = (con == null || con.start == null || con.end == null) ? 0 : (con.start.equals(Utils.toCC(this)) && con.end != null) ? con.end.getX() - getPos().getX() : (con.end.equals(Utils.toCC(this)) && con.start != null) ? con.start.getX() - getPos().getX() : 0;
int zDif = (con == null || con.start == null || con.end == null) ? 0 : (con.start.equals(Utils.toCC(this)) && con.end != null) ? con.end.getZ() - getPos().getZ() : (con.end.equals(Utils.toCC(this)) && con.start != null) ? con.start.getZ() - getPos().getZ() : 0;
if (facing.getAxis() == Axis.X)
return new Vec3d(.5, .4375, zDif > 0 ? .8125 : .1875);
else
return new Vec3d(xDif > 0 ? .8125 : .1875, .4375, .5);
}
Aggregations