Search in sources :

Example 71 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class ExitRoute method readRouter.

@SideOnly(Side.CLIENT)
private IRouter readRouter(LPDataInput input) {
    DoubleCoordinates pos = new DoubleCoordinates(input);
    TileEntity tile = pos.getTileEntity(MainProxy.getClientMainWorld());
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
        return ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).getRouter();
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 72 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class TEControl method handleBlockUpdate.

public static void handleBlockUpdate(final World world, final LPWorldInfo info, BlockPos blockPos) {
    if (info.isSkipBlockUpdateForWorld()) {
        return;
    }
    if (info.getWorldTick() < 5) {
        return;
    }
    final DoubleCoordinates pos = new DoubleCoordinates(blockPos);
    if (info.getUpdateQueued().contains(pos)) {
        return;
    }
    if (!pos.blockExists(world)) {
        return;
    }
    final TileEntity tile = pos.getTileEntity(world);
    if (SimpleServiceLocator.enderIOProxy.isBundledPipe(tile)) {
        QueuedTasks.queueTask(() -> {
            for (EnumFacing dir : EnumFacing.VALUES) {
                DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
                if (!newPos.blockExists(world)) {
                    continue;
                }
                TileEntity nextTile = newPos.getTileEntity(world);
                if (nextTile instanceof LogisticsTileGenericPipe) {
                    ((LogisticsTileGenericPipe) nextTile).scheduleNeighborChange();
                }
            }
            return null;
        });
    }
    if (tile == null || ((ILPTEInformation) tile).getObject() == null) {
        return;
    }
    if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile) || SimpleServiceLocator.specialtileconnection.isType(tile)) {
        info.getUpdateQueued().add(pos);
        QueuedTasks.queueTask(() -> {
            for (EnumFacing dir : EnumFacing.VALUES) {
                DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
                if (!newPos.blockExists(world)) {
                    continue;
                }
                TileEntity nextTile = newPos.getTileEntity(world);
                if (nextTile != null && ((ILPTEInformation) nextTile).getObject() != null) {
                    for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) nextTile).getObject().changeListeners)) {
                        listener.pipeModified(pos);
                    }
                }
            }
            for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) tile).getObject().changeListeners)) {
                listener.pipeModified(pos);
            }
            info.getUpdateQueued().remove(pos);
            return null;
        });
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) ITileEntityChangeListener(logisticspipes.asm.te.ITileEntityChangeListener) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ArrayList(java.util.ArrayList) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 73 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LPDuctUnitItem method isLPBlockedSide.

public boolean isLPBlockedSide(int paramInt, boolean ignoreSystemDisconnect) {
    EnumFacing dir = EnumFacing.getFront(paramInt);
    AxisAlignedBB aabb = PIPE_CONN_BB.get(paramInt);
    if (SimpleServiceLocator.mcmpProxy.checkIntersectionWith(pipe, aabb)) {
        return true;
    }
    if (pipe.getTileCache() == null) {
        DoubleCoordinates coords = new DoubleCoordinates(pipe.getTile().getPos());
        if (CoordinateUtils.add(coords, dir, 1).getTileEntity(pipe.getWorld()) instanceof LogisticsTileGenericPipe) {
            return true;
        }
    } else if (pipe.getTileCache()[dir.ordinal()].getTile() instanceof LogisticsTileGenericPipe) {
        return true;
    }
    if (pipe.pipe != null && pipe.pipe.isSideBlocked(dir, ignoreSystemDisconnect)) {
        return false;
    }
    TDPart.callSuperSideBlock = true;
    boolean re = parent.isSideBlocked(paramInt);
    TDPart.callSuperSideBlock = false;
    return re;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 74 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class ClientViewController method handlePacket.

public void handlePacket(RoutingUpdateCanidatePipe routingUpdateCanidatePipe) {
    DoubleCoordinates pos = routingUpdateCanidatePipe.getExitRoute().destination.getLPPosition();
    canidates.add(routingUpdateCanidatePipe.getExitRoute().destination.getLPPosition());
    // listHUD.add(new HUDRoutingTableDebugProvider(new HUDRoutingTableNewCandateUntrace(routingUpdateCanidatePipe.getExitRoute()), pos));
    getDebugInformation(pos).isNew = true;
    getDebugInformation(pos).newIndex = routingUpdateCanidatePipe.getExitRoute().debug.index;
}
Also used : DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 75 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsProgramCompilerTileEntity method update.

@Override
public void update() {
    super.update();
    if (MainProxy.isServer(world)) {
        if (currentTask != null) {
            wasAbleToConsumePower = false;
            for (EnumFacing dir : EnumFacing.VALUES) {
                if (dir == EnumFacing.UP)
                    continue;
                DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
                TileEntity tile = pos.getTileEntity(getWorld());
                if (!(tile instanceof LogisticsTileGenericPipe)) {
                    continue;
                }
                LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
                if (!(tPipe.pipe.getClass() == PipeItemsBasicLogistics.class)) {
                    continue;
                }
                CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
                if (pipe.useEnergy(10)) {
                    if (taskType.equals("category")) {
                        taskProgress += 0.0005;
                    } else if (taskType.equals("program")) {
                        taskProgress += 0.0025;
                    } else if (taskType.equals("flash")) {
                        taskProgress += 0.01;
                    } else {
                        taskProgress += 1;
                    }
                    wasAbleToConsumePower = true;
                }
            }
            if (taskProgress >= 1) {
                if (taskType.equals("category")) {
                    NBTTagList list = getNBTTagListForKey("compilerCategories");
                    list.appendTag(new NBTTagString(currentTask.toString()));
                } else if (taskType.equals("program")) {
                    NBTTagList list = getNBTTagListForKey("compilerPrograms");
                    list.appendTag(new NBTTagString(currentTask.toString()));
                } else if (taskType.equals("flash")) {
                    if (!getInventory().getStackInSlot(1).isEmpty()) {
                        ItemStack programmer = getInventory().getStackInSlot(1);
                        if (!programmer.hasTagCompound()) {
                            programmer.setTagCompound(new NBTTagCompound());
                        }
                        programmer.getTagCompound().setString(ItemLogisticsProgrammer.RECIPE_TARGET, currentTask.toString());
                    }
                } else {
                    throw new UnsupportedOperationException(taskType);
                }
                taskType = "";
                currentTask = null;
                taskProgress = 0;
                wasAbleToConsumePower = false;
            }
            updateClient();
        }
    }
}
Also used : IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) NBTTagString(net.minecraft.nbt.NBTTagString) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemStack(net.minecraft.item.ItemStack)

Aggregations

DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)94 TileEntity (net.minecraft.tileentity.TileEntity)57 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)22 LPPositionSet (logisticspipes.utils.LPPositionSet)19 ArrayList (java.util.ArrayList)17 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)15 EnumFacing (net.minecraft.util.EnumFacing)14 ItemStack (net.minecraft.item.ItemStack)12 World (net.minecraft.world.World)12 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)11 Block (net.minecraft.block.Block)11 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)7 List (java.util.List)7 DoubleCoordinatesType (network.rs485.logisticspipes.world.DoubleCoordinatesType)7 ILPTEInformation (logisticspipes.asm.te.ILPTEInformation)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 DockingStation (buildcraft.api.robots.DockingStation)5