use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class HSTubeCurve method getTubeOrientation.
@Override
public ITubeOrientation getTubeOrientation(EntityPlayer player, int xPos, int zPos) {
double x = xPos + 0.5 - player.posX;
double z = zPos + 0.5 - player.posZ;
double w = Math.atan2(x, z);
double halfPI = Math.PI / 2;
double halfhalfPI = halfPI / 2;
w -= halfhalfPI;
if (w < 0) {
w += 2 * Math.PI;
}
ForgeDirection dir = ForgeDirection.UNKNOWN;
ForgeDirection dir1 = ForgeDirection.UNKNOWN;
ForgeDirection dir2 = ForgeDirection.UNKNOWN;
double addition = 0;
if (0 < w && w <= halfPI) {
dir = ForgeDirection.WEST;
dir1 = ForgeDirection.NORTH;
dir2 = ForgeDirection.SOUTH;
addition = halfPI;
} else if (halfPI < w && w <= 2 * halfPI) {
dir = ForgeDirection.SOUTH;
dir1 = ForgeDirection.EAST;
dir2 = ForgeDirection.WEST;
} else if (2 * halfPI < w && w <= 3 * halfPI) {
dir = ForgeDirection.EAST;
dir1 = ForgeDirection.NORTH;
dir2 = ForgeDirection.SOUTH;
addition = halfPI;
} else if (3 * halfPI < w && w <= 4 * halfPI) {
dir = ForgeDirection.NORTH;
dir1 = ForgeDirection.EAST;
dir2 = ForgeDirection.WEST;
}
w = Math.atan2(player.getLookVec().xCoord, player.getLookVec().zCoord);
w -= addition;
if (w < 0) {
w += 2 * Math.PI;
}
ForgeDirection dir3 = ForgeDirection.UNKNOWN;
if (0 < w && w <= 2 * halfPI) {
dir3 = dir1;
} else if (2 * halfPI < w && w <= 4 * halfPI) {
dir3 = dir2;
}
for (CurveOrientation curve : CurveOrientation.values()) {
if (curve.from.equals(dir)) {
if (curve.looking.equals(dir3)) {
return curve;
}
}
}
return null;
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class HSTubeGain method getTubeOrientation.
@Override
public ITubeOrientation getTubeOrientation(EntityPlayer player, int xPos, int zPos) {
double x = xPos + 0.5 - player.posX;
double z = zPos + 0.5 - player.posZ;
double w = Math.atan2(x, z);
double halfPI = Math.PI / 2;
double halfhalfPI = halfPI / 2;
w -= halfhalfPI;
if (w < 0) {
w += 2 * Math.PI;
}
ForgeDirection dir = ForgeDirection.UNKNOWN;
if (0 < w && w <= halfPI) {
dir = ForgeDirection.EAST;
} else if (halfPI < w && w <= 2 * halfPI) {
dir = ForgeDirection.NORTH;
} else if (2 * halfPI < w && w <= 3 * halfPI) {
dir = ForgeDirection.WEST;
} else if (3 * halfPI < w && w <= 4 * halfPI) {
dir = ForgeDirection.SOUTH;
}
for (TubeGainOrientation ori : TubeGainOrientation.values()) {
if (ori.dir.equals(dir)) {
return ori;
}
}
return null;
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class HSTubeSCurve method getTubeOrientation.
@Override
public ITubeOrientation getTubeOrientation(EntityPlayer player, int xPos, int zPos) {
double x = xPos + 0.5 - player.posX;
double z = zPos + 0.5 - player.posZ;
double w = Math.atan2(x, z);
double halfPI = Math.PI / 2;
double halfhalfPI = halfPI / 2;
w -= halfhalfPI;
if (w < 0) {
w += 2 * Math.PI;
}
ForgeDirection dir = ForgeDirection.UNKNOWN;
ForgeDirection dir1 = ForgeDirection.UNKNOWN;
ForgeDirection dir2 = ForgeDirection.UNKNOWN;
double addition = 0;
if (0 < w && w <= halfPI) {
dir = ForgeDirection.EAST;
dir1 = ForgeDirection.NORTH;
dir2 = ForgeDirection.SOUTH;
addition = halfPI;
} else if (halfPI < w && w <= 2 * halfPI) {
dir = ForgeDirection.NORTH;
dir1 = ForgeDirection.EAST;
dir2 = ForgeDirection.WEST;
} else if (2 * halfPI < w && w <= 3 * halfPI) {
dir = ForgeDirection.WEST;
dir1 = ForgeDirection.NORTH;
dir2 = ForgeDirection.SOUTH;
addition = halfPI;
} else if (3 * halfPI < w && w <= 4 * halfPI) {
dir = ForgeDirection.SOUTH;
dir1 = ForgeDirection.EAST;
dir2 = ForgeDirection.WEST;
}
w = Math.atan2(player.getLookVec().xCoord, player.getLookVec().zCoord);
w -= addition;
if (w < 0) {
w += 2 * Math.PI;
}
ForgeDirection dir3 = ForgeDirection.UNKNOWN;
if (0 < w && w <= 2 * halfPI) {
dir3 = dir1;
} else if (2 * halfPI < w && w <= 4 * halfPI) {
dir3 = dir2;
}
for (CurveSOrientation curve : CurveSOrientation.values()) {
if (curve.dir.equals(dir)) {
if (curve.looking.equals(dir3)) {
return curve;
}
}
}
return null;
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class SneakyUpgradeConfig method getSide.
public ForgeDirection getSide(ItemStack stack) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound nbt = stack.getTagCompound();
String sideString = nbt.getString(SIDE_KEY);
return Arrays.stream(Sides.values()).filter(side -> side.getLpName().equals(sideString)).map(Sides::getDir).findFirst().orElse(ForgeDirection.UNKNOWN);
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class BCPipeInformationProvider method getDistanceTo.
@Override
public double getDistanceTo(int destinationint, ForgeDirection ignore, ItemIdentifier ident, boolean isActive, double traveled, double max, List<DoubleCoordinates> visited) {
if (traveled >= max) {
return Integer.MAX_VALUE;
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (ignore == dir) {
continue;
}
IPipeInformationProvider information = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(getNextConnectedTile(dir));
if (information != null) {
DoubleCoordinates pos = new DoubleCoordinates(information);
if (visited.contains(pos)) {
continue;
}
visited.add(pos);
double result = information.getDistanceTo(destinationint, dir.getOpposite(), ident, isActive, traveled + getDistance(), max, visited);
visited.remove(pos);
if (result == Integer.MAX_VALUE) {
return result;
}
return result + (int) getDistance();
}
}
return Integer.MAX_VALUE;
}
Aggregations