use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class TextureMatrix method refreshStates.
public void refreshStates(CoreUnroutedPipe pipe) {
if (textureIndex != pipe.getTextureIndex()) {
dirty = true;
}
textureIndex = pipe.getTextureIndex();
if (isRouted != pipe.isRoutedPipe()) {
dirty = true;
}
isRouted = pipe.isRoutedPipe();
if (isRouted) {
CoreRoutedPipe cPipe = (CoreRoutedPipe) pipe;
for (int i = 0; i < 6; i++) {
if (isRoutedInDir[i] != cPipe.getRouter().isRoutedExit(ForgeDirection.getOrientation(i))) {
dirty = true;
}
isRoutedInDir[i] = cPipe.getRouter().isRoutedExit(ForgeDirection.getOrientation(i));
}
for (int i = 0; i < 6; i++) {
if (isSubPowerInDir[i] != cPipe.getRouter().isSubPoweredExit(ForgeDirection.getOrientation(i))) {
dirty = true;
}
isSubPowerInDir[i] = cPipe.getRouter().isSubPoweredExit(ForgeDirection.getOrientation(i));
}
if (hasPowerUpgrade != (cPipe.getUpgradeManager().hasRFPowerSupplierUpgrade() || cPipe.getUpgradeManager().getIC2PowerLevel() > 0)) {
dirty = true;
}
hasPowerUpgrade = cPipe.getUpgradeManager().hasRFPowerSupplierUpgrade() || cPipe.getUpgradeManager().getIC2PowerLevel() > 0;
if (hasPower != (cPipe._textureBufferPowered || Configs.LOGISTICS_POWER_USAGE_DISABLED)) {
dirty = true;
}
hasPower = cPipe._textureBufferPowered || Configs.LOGISTICS_POWER_USAGE_DISABLED;
if (isFluid != cPipe.isFluidPipe()) {
dirty = true;
}
isFluid = cPipe.isFluidPipe();
if (pointedOrientation != cPipe.getPointedOrientation()) {
dirty = true;
}
pointedOrientation = cPipe.getPointedOrientation();
} else {
isRoutedInDir = new boolean[6];
}
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class RequestTreeNode method getCrafters.
private static List<Pair<ICraftingTemplate, List<IFilter>>> getCrafters(IResource iRequestType, List<ExitRoute> validDestinations) {
List<Pair<ICraftingTemplate, List<IFilter>>> crafters = new ArrayList<>(validDestinations.size());
for (ExitRoute r : validDestinations) {
CoreRoutedPipe pipe = r.destination.getPipe();
if (r.containsFlag(PipeRoutingConnectionType.canRequestFrom)) {
if (pipe instanceof ICraft) {
ICraftingTemplate craftable = ((ICraft) pipe).addCrafting(iRequestType);
if (craftable != null) {
for (IFilter filter : r.filters) {
if (filter.isBlocked() == filter.isFilteredItem(craftable.getResultItem()) || filter.blockCrafting()) {
continue;
}
}
List<IFilter> list = new LinkedList<>();
list.addAll(r.filters);
crafters.add(new Pair<>(craftable, list));
}
}
}
}
// Collections.sort(crafters,new CraftingTemplate.PairPrioritizer());
return crafters;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class ClientRouter method getPipe.
@Override
public CoreRoutedPipe getPipe() {
World worldObj = MainProxy.proxy.getWorld();
if (worldObj == null) {
return null;
}
TileEntity tile = worldObj.getTileEntity(_xCoord, _yCoord, _zCoord);
if (!(tile instanceof LogisticsTileGenericPipe)) {
return null;
}
LogisticsTileGenericPipe pipe = (LogisticsTileGenericPipe) tile;
if (!(pipe.pipe instanceof CoreRoutedPipe)) {
return null;
}
return (CoreRoutedPipe) pipe.pipe;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class LogisticsSolderingTileEntity method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (MainProxy.isClient(getWorldObj())) {
return;
}
hasWork = hasWork();
if (hasWork && heat < 100) {
boolean usedEnergy = false;
if (Configs.LOGISTICS_POWER_USAGE_DISABLED) {
if (heat < 100) {
heat += 5;
}
if (heat > 100) {
heat = 100;
}
usedEnergy = true;
} else {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity tile = pos.getTileEntity(getWorldObj());
if (!(tile instanceof LogisticsTileGenericPipe)) {
continue;
}
LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
if (!(tPipe.pipe instanceof CoreRoutedPipe)) {
continue;
}
CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
if (pipe.useEnergy(50)) {
heat += 5;
if (heat > 100) {
heat = 100;
}
updateHeat();
usedEnergy = true;
break;
}
}
}
if (!usedEnergy && getWorldObj().getTotalWorldTime() % 5 == 0) {
heat--;
if (heat < 0) {
heat = 0;
}
updateHeat();
}
} else if (!hasWork && heat > 0) {
heat--;
updateHeat();
}
if (hasWork && heat >= 100) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity tile = pos.getTileEntity(getWorldObj());
if (!(tile instanceof LogisticsTileGenericPipe)) {
continue;
}
LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
if (!(tPipe.pipe instanceof CoreRoutedPipe)) {
continue;
}
CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
if (pipe.useEnergy(30)) {
progress += 3;
} else if (pipe.useEnergy(20)) {
progress += 2;
} else if (pipe.useEnergy(10)) {
progress += 1;
}
if (progress >= 100) {
if (tryCraft()) {
progress = 0;
} else {
progress -= 50;
}
}
updateProgress();
}
} else if (!hasWork && progress != 0) {
progress = 0;
updateProgress();
}
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class LogisticsEventListener method onPlayerInteract.
@SubscribeEvent
public void onPlayerInteract(final PlayerInteractEvent event) {
if (MainProxy.isServer(event.entityPlayer.worldObj)) {
if (event.action == Action.LEFT_CLICK_BLOCK) {
final TileEntity tile = event.entityPlayer.worldObj.getTileEntity(event.x, event.y, event.z);
if (tile instanceof LogisticsTileGenericPipe) {
if (((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
if (!((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).canBeDestroyedByPlayer(event.entityPlayer)) {
event.setCanceled(true);
event.entityPlayer.addChatComponentMessage(new ChatComponentTranslation("lp.chat.permissiondenied"));
((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
event.entityPlayer.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).delayTo = System.currentTimeMillis() + 200;
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).repeatFor = 10;
} else {
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).setDestroyByPlayer();
}
}
}
}
if (event.action == Action.RIGHT_CLICK_BLOCK) {
WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.entityPlayer.worldObj, event.x, event.y, event.z);
TileEntity tileEntity = worldCoordinates.getTileEntity();
if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
//@formatter:off
List<WeakReference<ModuleQuickSort>> list = worldCoordinates.getAdjacentTileEntities().filter(adjacent -> adjacent.tileEntity instanceof LogisticsTileGenericPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe instanceof PipeLogisticsChassi).filter(adjacent -> ((PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).getPointedOrientation() == adjacent.direction.getOpposite()).map(adjacent -> (PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).flatMap(pipeLogisticsChassi -> Arrays.stream(pipeLogisticsChassi.getModules().getModules())).filter(logisticsModule -> logisticsModule instanceof ModuleQuickSort).map(logisticsModule -> new WeakReference<>((ModuleQuickSort) logisticsModule)).collect(Collectors.toList());
if (!list.isEmpty()) {
LogisticsEventListener.chestQuickSortConnection.put(event.entityPlayer, list);
}
}
}
}
}
Aggregations