Search in sources :

Example 81 with LogisticsTileGenericPipe

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

the class ServerRouter method getPipe.

@Override
public CoreRoutedPipe getPipe() {
    CoreRoutedPipe crp = getCachedPipe();
    if (crp != null) {
        return crp;
    }
    World world = DimensionManager.getWorld(_dimension);
    if (world == null) {
        return null;
    }
    TileEntity tile = world.getTileEntity(new BlockPos(_xCoord, _yCoord, _zCoord));
    if (!(tile instanceof LogisticsTileGenericPipe)) {
        return null;
    }
    LogisticsTileGenericPipe pipe = (LogisticsTileGenericPipe) tile;
    if (!(pipe.pipe instanceof CoreRoutedPipe)) {
        return null;
    }
    _myPipeCache = new WeakReference<>((CoreRoutedPipe) pipe.pipe);
    return (CoreRoutedPipe) pipe.pipe;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 82 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe 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 83 with LogisticsTileGenericPipe

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

the class PipeTransportLogistics method handleItemPositionPacket.

public void handleItemPositionPacket(int travelId, EnumFacing input, EnumFacing output, float speed, float position, float yaw) {
    WeakReference<LPTravelingItemClient> ref = LPTravelingItem.clientList.get(travelId);
    LPTravelingItemClient item = null;
    if (ref != null) {
        item = ref.get();
    }
    if (item == null) {
        sendItemContentRequest(travelId);
        item = new LPTravelingItemClient(travelId, position, input, output, yaw);
        item.setSpeed(speed);
        LPTravelingItem.clientList.put(travelId, new WeakReference<>(item));
    } else {
        if (item.getContainer() instanceof LogisticsTileGenericPipe) {
            ((LogisticsTileGenericPipe) item.getContainer()).pipe.transport.items.scheduleRemoval(item);
            ((LogisticsTileGenericPipe) item.getContainer()).pipe.transport.items.removeScheduledItems();
        }
        item.updateInformation(input, output, speed, position, yaw);
    }
    // update lastTicked so we don't double-move items
    item.lastTicked = MainProxy.getGlobalTick();
    if (items.get(travelId) == null) {
        items.add(item);
    }
// getPipe().spawnParticle(Particles.OrangeParticle, 1);
}
Also used : LPTravelingItemClient(logisticspipes.transport.LPTravelingItem.LPTravelingItemClient) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 84 with LogisticsTileGenericPipe

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

the class PipeMultiBlockTransportLogistics method handleTileReachedClient.

@Override
protected void handleTileReachedClient(LPTravelingItemClient arrivingItem, TileEntity tile, EnumFacing dir) {
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreMultiBlockPipe) {
        passToNextPipe(arrivingItem, tile);
        return;
    } else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> masterTile = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        if (!masterTile.isEmpty()) {
            if (masterTile.size() > 1) {
                throw new UnsupportedOperationException();
            }
            passToNextPipe(arrivingItem, masterTile.get(0));
            return;
        }
    }
    Explosion explosion = new Explosion(this.getWorld(), null, this.getPipe().getX(), this.getPipe().getY(), this.getPipe().getZ(), 4.0F, false, true);
    explosion.doExplosionB(true);
}
Also used : Explosion(net.minecraft.world.Explosion) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) List(java.util.List)

Example 85 with LogisticsTileGenericPipe

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

the class LogisticsEventListener method onPlayerLeftClickBlock.

@SubscribeEvent
public void onPlayerLeftClickBlock(final PlayerInteractEvent.LeftClickBlock event) {
    if (MainProxy.isServer(event.getEntityPlayer().world)) {
        final TileEntity tile = event.getEntityPlayer().world.getTileEntity(event.getPos());
        if (tile instanceof LogisticsTileGenericPipe) {
            if (((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
                if (!((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).canBeDestroyedByPlayer(event.getEntityPlayer())) {
                    event.setCanceled(true);
                    event.getEntityPlayer().sendMessage(new TextComponentTranslation("lp.chat.permissiondenied"));
                    ((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
                    World world = event.getEntityPlayer().world;
                    BlockPos pos = tile.getPos();
                    IBlockState state = world.getBlockState(pos);
                    world.markAndNotifyBlock(tile.getPos(), world.getChunkFromBlockCoords(pos), state, state, 2);
                    ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).delayTo = System.currentTimeMillis() + 200;
                    ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).repeatFor = 10;
                } else {
                    ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).setDestroyByPlayer();
                }
            }
        }
    }
}
Also used : NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBlockState(net.minecraft.block.state.IBlockState) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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