use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.
the class ChassisGuiProvider method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
LogisticsTileGenericPipe pipe = getTileAs(player.world, LogisticsTileGenericPipe.class);
if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
return null;
}
final PipeLogisticsChassis _chassiPipe = (PipeLogisticsChassis) pipe.pipe;
IInventory _moduleInventory = _chassiPipe.getModuleInventory();
DummyContainer dummy = new DummyContainer(player.inventory, _moduleInventory);
if (_chassiPipe.getChassisSize() < 5) {
dummy.addNormalSlotsForPlayerInventory(18, 97);
} else {
dummy.addNormalSlotsForPlayerInventory(18, 174);
}
for (int i = 0; i < _chassiPipe.getChassisSize(); i++) {
dummy.addModuleSlot(i, _moduleInventory, 19, 9 + 20 * i, _chassiPipe);
}
if (_chassiPipe.getUpgradeManager().hasUpgradeModuleUpgrade()) {
for (int i = 0; i < _chassiPipe.getChassisSize(); i++) {
final int fI = i;
ModuleUpgradeManager upgradeManager = _chassiPipe.getModuleUpgradeManager(i);
dummy.addUpgradeSlot(0, upgradeManager, 0, 145, 9 + i * 20, itemStack -> ChassisGuiProvider.checkStack(itemStack, _chassiPipe, fI));
dummy.addUpgradeSlot(1, upgradeManager, 1, 165, 9 + i * 20, itemStack -> ChassisGuiProvider.checkStack(itemStack, _chassiPipe, fI));
}
}
return dummy;
}
use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.
the class LogisticsEventListener method onPlayerLeftClickBlock.
@SubscribeEvent
public void onPlayerLeftClickBlock(final PlayerInteractEvent.RightClickBlock event) {
if (MainProxy.isServer(event.getEntityPlayer().world)) {
WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.getEntityPlayer().world, event.getPos());
TileEntity tileEntity = worldCoordinates.getTileEntity();
if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
List<WeakReference<AsyncQuicksortModule>> list = worldCoordinates.allNeighborTileEntities().stream().filter(NeighborTileEntity::isLogisticsPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe instanceof PipeLogisticsChassis).filter(adjacent -> ((PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).getPointedOrientation() == adjacent.getOurDirection()).map(adjacent -> (PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).flatMap(chassis -> chassis.getModules().getModules()).filter(logisticsModule -> logisticsModule instanceof AsyncQuicksortModule).map(logisticsModule -> new WeakReference<>((AsyncQuicksortModule) logisticsModule)).collect(Collectors.toList());
if (!list.isEmpty()) {
LogisticsEventListener.chestQuickSortConnection.put(event.getEntityPlayer(), list);
}
}
}
}
use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.
the class AdvancedExtractorSneakyGuiPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
if (getType() == ModulePositionType.IN_HAND) {
if (player.openContainer instanceof DummyModuleContainer) {
DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
if (dummy.getModule() instanceof AsyncAdvancedExtractor) {
player.closeScreen();
NewGuiHandler.getGui(SneakyModuleInHandGuiProvider.class).setInvSlot(getPositionInt()).open(player);
}
}
return;
}
PipeLogisticsChassis pipe = getTileOrPipe(player.world, PipeLogisticsChassis.class);
LogisticsModule subModule = pipe.getSubModule(getPositionInt());
if (subModule instanceof AsyncAdvancedExtractor) {
NewGuiHandler.getGui(SneakyModuleInSlotGuiProvider.class).setSneakyOrientation(((AsyncAdvancedExtractor) subModule).getSneakyDirection()).setSlot(getType()).setPositionInt(getPositionInt()).setPosX(getPosX()).setPosY(getPosY()).setPosZ(getPosZ()).open(player);
}
}
use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.
the class PipeTransportLogistics method handleTileReachedServer_internal.
protected final void handleTileReachedServer_internal(LPTravelingItemServer arrivingItem, TileEntity tile, EnumFacing dir) {
if (getPipe() instanceof PipeItemsFluidSupplier) {
((PipeItemsFluidSupplier) getPipe()).endReached(arrivingItem, tile);
if (arrivingItem.getItemIdentifierStack().getStackSize() <= 0) {
return;
}
}
markChunkModified(tile);
if (arrivingItem.getInfo() != null && arrivingItem.getArrived() && isRouted) {
getRoutedPipe().notifyOfItemArival(arrivingItem.getInfo());
}
if (getPipe() instanceof FluidRoutedPipe) {
if (((FluidRoutedPipe) getPipe()).endReached(arrivingItem, tile)) {
return;
}
}
boolean isSpecialConnectionInformationTransition = false;
if (SimpleServiceLocator.specialtileconnection.needsInformationTransition(tile)) {
isSpecialConnectionInformationTransition = true;
SimpleServiceLocator.specialtileconnection.transmit(tile, arrivingItem);
}
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
if (passToNextPipe(arrivingItem, tile)) {
return;
}
} else {
IInventoryUtil util = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(tile, dir.getOpposite());
if (util != null && isRouted) {
getRoutedPipe().getCacheHolder().trigger(CacheTypes.Inventory);
// destroy the item on exit if it isn't exitable
if (!isSpecialConnectionInformationTransition && isItemUnwanted(arrivingItem.getItemIdentifierStack())) {
return;
}
// last chance for chassi to back out
if (arrivingItem.getTransportMode() != TransportMode.Active && !getRoutedPipe().getTransportLayer().stillWantItem(arrivingItem)) {
reverseItem(arrivingItem);
return;
}
final ISlotUpgradeManager slotManager;
{
ModulePositionType slot = null;
int positionInt = -1;
if (arrivingItem.getInfo().targetInfo instanceof ChassiTargetInformation) {
positionInt = ((ChassiTargetInformation) arrivingItem.getInfo().targetInfo).getModuleSlot();
slot = ModulePositionType.SLOT;
} else if (LogisticsPipes.isDEBUG() && container.pipe instanceof PipeLogisticsChassis) {
System.out.println(arrivingItem);
new RuntimeException("[ItemInsertion] Information weren't ment for a chassi pipe").printStackTrace();
}
slotManager = getRoutedPipe().getUpgradeManager(slot, positionInt);
}
if (arrivingItem.getAdditionalTargetInformation() instanceof ITargetSlotInformation) {
ITargetSlotInformation information = (ITargetSlotInformation) arrivingItem.getAdditionalTargetInformation();
if (util instanceof ISpecialInsertion) {
int slot = information.getTargetSlot();
int amount = information.getAmount();
if (util.getSizeInventory() > slot) {
ItemStack content = util.getStackInSlot(slot);
ItemStack toAdd = arrivingItem.getItemIdentifierStack().makeNormalStack();
final int amountLeft = Math.max(0, amount - content.getCount());
toAdd.setCount(Math.min(toAdd.getCount(), amountLeft));
if (toAdd.getCount() > 0) {
if (util.getSizeInventory() > slot) {
int added = ((ISpecialInsertion) util).addToSlot(toAdd, slot);
arrivingItem.getItemIdentifierStack().lowerStackSize(added);
}
}
}
if (information.isLimited()) {
if (arrivingItem.getItemIdentifierStack().getStackSize() > 0) {
reverseItem(arrivingItem);
}
return;
}
}
}
// sneaky insertion
if (!getRoutedPipe().getUpgradeManager().hasCombinedSneakyUpgrade() || slotManager.hasOwnSneakyUpgrade()) {
EnumFacing insertion = arrivingItem.output.getOpposite();
if (slotManager.hasSneakyUpgrade()) {
insertion = slotManager.getSneakyOrientation();
}
if (insertArrivingItem(arrivingItem, tile, insertion))
return;
} else {
EnumFacing[] dirs = getRoutedPipe().getUpgradeManager().getCombinedSneakyOrientation();
for (EnumFacing insertion : dirs) {
if (insertion == null) {
continue;
}
if (insertArrivingItem(arrivingItem, tile, insertion))
return;
}
}
if (arrivingItem.getItemIdentifierStack().getStackSize() > 0) {
reverseItem(arrivingItem);
}
// the item is handled
return;
}
// end of insert into IInventory
}
dropItem(arrivingItem);
}
use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.
the class ModuleCoordinatesGuiProvider method getLogisticsModule.
@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(World world, Class<T> clazz) {
LogisticsTileGenericPipe pipe = getTileAs(world, LogisticsTileGenericPipe.class);
if (!(pipe.pipe instanceof CoreRoutedPipe)) {
if (LogisticsPipes.isDEBUG() && pipe.isInitialized()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", pipe didn't exsist").printStackTrace();
}
return null;
}
LogisticsModule module;
if (slot == ModulePositionType.IN_PIPE) {
module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
} else if (slot == ModulePositionType.IN_HAND) {
throw new UnsupportedOperationException("NO IN_HAND FOR THIS PACKET TYPE");
} else {
if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
if (LogisticsPipes.isDEBUG()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe").printStackTrace();
}
return null;
}
module = ((PipeLogisticsChassis) pipe.pipe).getSubModule(positionInt);
}
if (module != null) {
if (!(clazz.isAssignableFrom(module.getClass()))) {
if (LogisticsPipes.isDEBUG()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", found " + module.getClass()).printStackTrace();
}
return null;
}
} else {
if (LogisticsPipes.isDEBUG()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName()).printStackTrace();
}
}
return (T) module;
}
Aggregations