Search in sources :

Example 31 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class SendQueueContent method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
    if (pipe == null) {
        return;
    }
    if (pipe.pipe instanceof ISendQueueContentRecieiver) {
        ISendQueueContentRecieiver receiver = (ISendQueueContentRecieiver) pipe.pipe;
        receiver.handleSendQueueItemIdentifierList(getIdentList());
    }
}
Also used : ISendQueueContentRecieiver(logisticspipes.interfaces.ISendQueueContentRecieiver) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 32 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class SlotFinderOpenGuiPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    // hack to avoid wrenching blocks
    int savedEquipped = player.inventory.currentItem;
    boolean foundSlot = false;
    // try to find a empty slot
    for (int i = 0; i < 9; i++) {
        if (player.inventory.getStackInSlot(i).isEmpty()) {
            foundSlot = true;
            player.inventory.currentItem = i;
            break;
        }
    }
    // okay, anything that's a block?
    if (!foundSlot) {
        for (int i = 0; i < 9; i++) {
            ItemStack is = player.inventory.getStackInSlot(i);
            if (!is.isEmpty() && is.getItem() instanceof ItemBlock) {
                foundSlot = true;
                player.inventory.currentItem = i;
                break;
            }
        }
    }
    // give up and select whatever is right of the current slot
    if (!foundSlot) {
        player.inventory.currentItem = (player.inventory.currentItem + 1) % 9;
    }
    boolean openedGui = false;
    final LogisticsTileGenericPipe genericPipe = getPipe(player.world, LTGPCompletionCheck.PIPE);
    if (genericPipe.isRoutingPipe()) {
        openedGui = genericPipe.getRoutingPipe().getAvailableAdjacent().inventories().stream().filter(neighbor -> LPNeighborTileEntityKt.getInventoryUtil(neighbor) instanceof ISpecialInsertion).anyMatch(neighbor -> {
            for (ICraftingRecipeProvider provider : SimpleServiceLocator.craftingRecipeProviders) {
                if (provider.canOpenGui(neighbor.getTileEntity())) {
                    return true;
                }
            }
            Block block = neighbor.getTileEntity().getBlockType();
            final BlockPos blockPos = neighbor.getTileEntity().getPos();
            final IBlockState blockState = player.world.getBlockState(blockPos);
            if (!block.isAir(blockState, player.world, blockPos)) {
                int xCoord = blockPos.getX();
                int yCoord = blockPos.getY();
                int zCoord = blockPos.getZ();
                if (SimpleServiceLocator.enderStorageProxy.isEnderChestBlock(block)) {
                    SimpleServiceLocator.enderStorageProxy.openEnderChest(player.world, xCoord, yCoord, zCoord, player);
                    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SlotFinderActivatePacket.class).setTagetPosX(xCoord).setTagetPosY(yCoord).setTagetPosZ(zCoord).setSlot(getSlot()).setPacketPos(this), player);
                    return true;
                }
                if (block.onBlockActivated(player.world, blockPos, blockState, player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0)) {
                    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SlotFinderActivatePacket.class).setTagetPosX(xCoord).setTagetPosY(yCoord).setTagetPosZ(zCoord).setSlot(getSlot()).setPacketPos(this), player);
                    return true;
                }
            }
            return false;
        });
    }
    if (!openedGui) {
        LogisticsPipes.log.warn("Ignored SlotFinderOpenGuiPacket from " + player.toString() + ", because of failing preconditions");
    }
    player.inventory.currentItem = savedEquipped;
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) Setter(lombok.Setter) ISpecialInsertion(logisticspipes.interfaces.ISpecialInsertion) Getter(lombok.Getter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) LPDataInput(network.rs485.logisticspipes.util.LPDataInput) LogisticsPipes(logisticspipes.LogisticsPipes) EnumHand(net.minecraft.util.EnumHand) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) PacketHandler(logisticspipes.network.PacketHandler) MainProxy(logisticspipes.proxy.MainProxy) LPDataOutput(network.rs485.logisticspipes.util.LPDataOutput) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer) StaticResolve(logisticspipes.utils.StaticResolve) LPNeighborTileEntityKt(network.rs485.logisticspipes.connection.LPNeighborTileEntityKt) ItemBlock(net.minecraft.item.ItemBlock) ModuleCoordinatesPacket(logisticspipes.network.abstractpackets.ModuleCoordinatesPacket) ICraftingRecipeProvider(logisticspipes.proxy.interfaces.ICraftingRecipeProvider) ISpecialInsertion(logisticspipes.interfaces.ISpecialInsertion) IBlockState(net.minecraft.block.state.IBlockState) ICraftingRecipeProvider(logisticspipes.proxy.interfaces.ICraftingRecipeProvider) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 33 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class SatelliteSetNamePacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.PIPE);
    if (pipe == null || pipe.pipe == null) {
        return;
    }
    String newName = getString();
    SatelliteNamingResult result = null;
    if (newName.trim().isEmpty()) {
        result = SatelliteNamingResult.BLANK_NAME;
    } else if (pipe.pipe instanceof SatellitePipe) {
        final SatellitePipe satellitePipe = (SatellitePipe) pipe.pipe;
        if (satellitePipe.getSatellitesOfType().stream().anyMatch(it -> it.getSatellitePipeName().equals(newName))) {
            result = SatelliteNamingResult.DUPLICATE_NAME;
        } else {
            result = SatelliteNamingResult.SUCCESS;
            satellitePipe.setSatellitePipeName(newName);
            satellitePipe.updateWatchers();
            satellitePipe.ensureAllSatelliteStatus();
        }
    }
    if (result != null) {
        MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SetNameResult.class).setResult(result).setNewName(getString()), player);
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) SatellitePipe(network.rs485.logisticspipes.SatellitePipe) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) EntityPlayer(net.minecraft.entity.player.EntityPlayer) StaticResolve(logisticspipes.utils.StaticResolve) PacketHandler(logisticspipes.network.PacketHandler) MainProxy(logisticspipes.proxy.MainProxy) SatelliteNamingResult(logisticspipes.pipes.SatelliteNamingResult) StringCoordinatesPacket(logisticspipes.network.abstractpackets.StringCoordinatesPacket) SatellitePipe(network.rs485.logisticspipes.SatellitePipe) SatelliteNamingResult(logisticspipes.pipes.SatelliteNamingResult) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 34 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class OrdererRefreshRequestPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    int dimension = (getInteger() - (getInteger() % 10)) / 10;
    final LogisticsTileGenericPipe pipe = MainProxy.proxy.getPipeInDimensionAt(dimension, getPosX(), getPosY(), getPosZ(), player);
    if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
        return;
    }
    RequestHandler.DisplayOptions option;
    switch(getInteger() % 10) {
        case 0:
            option = RequestHandler.DisplayOptions.Both;
            break;
        case 1:
            option = RequestHandler.DisplayOptions.SupplyOnly;
            break;
        case 2:
            option = RequestHandler.DisplayOptions.CraftOnly;
            break;
        default:
            option = RequestHandler.DisplayOptions.Both;
            break;
    }
    RequestHandler.refresh(player, (CoreRoutedPipe) pipe.pipe, option);
}
Also used : RequestHandler(logisticspipes.request.RequestHandler) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 35 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class RequestSubmitListPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
    if (pipe == null) {
        return;
    }
    if (!(pipe.pipe instanceof PipeBlockRequestTable)) {
        return;
    }
    RequestHandler.requestList(player, getIdentList(), (CoreRoutedPipe) pipe.pipe);
}
Also used : PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Aggregations

LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)115 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)47 TileEntity (net.minecraft.tileentity.TileEntity)45 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)21 EnumFacing (net.minecraft.util.EnumFacing)15 ArrayList (java.util.ArrayList)14 List (java.util.List)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)10 BlockPos (net.minecraft.util.math.BlockPos)10 World (net.minecraft.world.World)9 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 HashMap (java.util.HashMap)8 LinkedList (java.util.LinkedList)8 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)8 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)7 MainProxy (logisticspipes.proxy.MainProxy)7 ExitRoute (logisticspipes.routing.ExitRoute)7 PipeLogisticsChassi (logisticspipes.pipes.PipeLogisticsChassi)6 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)6