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;
}
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;
});
}
}
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);
}
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);
}
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();
}
}
}
}
}
Aggregations