Search in sources :

Example 51 with ForgeDirection

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;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 52 with ForgeDirection

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;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 53 with ForgeDirection

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;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 54 with ForgeDirection

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);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NewGuiHandler(logisticspipes.network.NewGuiHandler) Arrays(java.util.Arrays) UpgradeCoordinatesGuiProvider(logisticspipes.network.abstractguis.UpgradeCoordinatesGuiProvider) Getter(lombok.Getter) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ModuleOreDictItemSink(logisticspipes.modules.ModuleOreDictItemSink) SneakyUpgradeConfigGuiProvider(logisticspipes.network.guis.upgrade.SneakyUpgradeConfigGuiProvider) ModuleCreativeTabBasedItemSink(logisticspipes.modules.ModuleCreativeTabBasedItemSink) ItemStack(net.minecraft.item.ItemStack) ModulePolymorphicItemSink(logisticspipes.modules.ModulePolymorphicItemSink) ModuleItemSink(logisticspipes.modules.ModuleItemSink) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ModuleModBasedItemSink(logisticspipes.modules.ModuleModBasedItemSink) AllArgsConstructor(lombok.AllArgsConstructor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 55 with ForgeDirection

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;
}
Also used : IPipeInformationProvider(logisticspipes.routing.pathfinder.IPipeInformationProvider) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Aggregations

ForgeDirection (net.minecraftforge.common.util.ForgeDirection)242 TileEntity (net.minecraft.tileentity.TileEntity)80 ItemStack (net.minecraft.item.ItemStack)47 ArrayList (java.util.ArrayList)29 Block (net.minecraft.block.Block)28 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)24 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)21 IInventory (net.minecraft.inventory.IInventory)19 FluidStack (net.minecraftforge.fluids.FluidStack)18 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)17 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)16 HashMap (java.util.HashMap)12 Pair (logisticspipes.utils.tuples.Pair)11 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)10 World (net.minecraft.world.World)10 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)9 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)9 List (java.util.List)8