use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class GuiChassiPipe method actionPerformed.
@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton.id >= 0 && guibutton.id <= 7) {
LogisticsModule module = _chassiPipe.getLogisticsModule().getSubModule(guibutton.id);
if (module != null) {
final ModernPacket packet = PacketHandler.getPacket(ChassisGUI.class).setButtonID(guibutton.id).setPosX(_chassiPipe.getX()).setPosY(_chassiPipe.getY()).setPosZ(_chassiPipe.getZ());
MainProxy.sendPacketToServer(packet);
}
}
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class ChassiTransportLayer method stillWantItem.
@Override
public boolean stillWantItem(IRoutedItem item) {
LogisticsModule module = _chassiPipe.getLogisticsModule();
if (module == null) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
if (!_chassiPipe.isEnabled()) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
SinkReply reply = module.sinksItem(item.getItemIdentifierStack().getItem(), -1, 0, true, false);
if (reply == null || reply.maxNumberOfItems < 0) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
if (reply.maxNumberOfItems > 0 && item.getItemIdentifierStack().getStackSize() > reply.maxNumberOfItems) {
ForgeDirection o = _chassiPipe.getPointedOrientation();
if (o == null || o == ForgeDirection.UNKNOWN) {
o = ForgeDirection.UP;
}
item.split(reply.maxNumberOfItems, o);
}
return true;
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class ChassiModule method sinksItem.
@Override
public SinkReply sinksItem(ItemIdentifier item, int bestPriority, int bestCustomPriority, boolean allowDefault, boolean includeInTransit) {
SinkReply bestresult = null;
for (LogisticsModule module : modules) {
if (module != null) {
SinkReply result = module.sinksItem(item, bestPriority, bestCustomPriority, allowDefault, includeInTransit);
if (result != null && result.maxNumberOfItems >= 0) {
bestresult = result;
bestPriority = result.fixedPriority.ordinal();
bestCustomPriority = result.customPriority;
}
}
}
if (bestresult == null) {
return null;
}
//Always deny items when we can't put the item anywhere
IInventoryUtil invUtil = parentChassis.getSneakyInventory(false, ModulePositionType.SLOT, ((ChassiTargetInformation) bestresult.addInfo).getModuleSlot());
if (invUtil == null) {
return null;
}
int roomForItem = invUtil.roomForItem(item);
if (roomForItem < 1) {
return null;
}
if (includeInTransit) {
int onRoute = parentChassis.countOnRoute(item);
roomForItem = invUtil.roomForItem(item, onRoute + item.getMaxStackSize());
roomForItem -= onRoute;
if (roomForItem < 1) {
return null;
}
}
if (bestresult.maxNumberOfItems == 0) {
return new SinkReply(bestresult, roomForItem);
}
return new SinkReply(bestresult, Math.min(bestresult.maxNumberOfItems, roomForItem));
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class ModuleInHandGuiProvider method getLogisticsModule.
public final LogisticsModule getLogisticsModule(EntityPlayer player) {
ItemStack item = player.inventory.mainInventory[invSlot];
if (item == null) {
return null;
}
LogisticsModule module = LogisticsPipes.ModuleItem.getModuleForItem(item, null, new DummyWorldProvider(player.getEntityWorld()), null);
module.registerPosition(ModulePositionType.IN_HAND, invSlot);
ItemModuleInformationManager.readInformation(item, module);
return module;
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method getSpecificInterests.
@Override
public Set<ItemIdentifier> getSpecificInterests() {
Set<ItemIdentifier> l1 = new TreeSet<>();
//if we don't have a pointed inventory we can't be interested in anything
if (getRealInventory() == null) {
return l1;
}
for (int moduleIndex = 0; moduleIndex < getChassiSize(); moduleIndex++) {
LogisticsModule module = _module.getSubModule(moduleIndex);
if (module != null && module.interestedInAttachedInventory()) {
IInventoryUtil inv = getSneakyInventory(false, module.getSlot(), module.getPositionInt());
if (inv == null) {
continue;
}
Set<ItemIdentifier> items = inv.getItems();
l1.addAll(items);
//also add tag-less variants ... we should probably add a module.interestedIgnoringNBT at some point
l1.addAll(items.stream().map(ItemIdentifier::getIgnoringNBT).collect(Collectors.toList()));
boolean modulesInterestedInUndamged = false;
for (int i = 0; i < getChassiSize(); i++) {
if (_module.getSubModule(moduleIndex).interestedInUndamagedID()) {
modulesInterestedInUndamged = true;
break;
}
}
if (modulesInterestedInUndamged) {
l1.addAll(items.stream().map(ItemIdentifier::getUndamaged).collect(Collectors.toList()));
}
// no need to check other modules for interest in the inventory, when we know that 1 already is.
break;
}
}
for (int i = 0; i < getChassiSize(); i++) {
LogisticsModule module = _module.getSubModule(i);
if (module != null) {
Collection<ItemIdentifier> current = module.getSpecificInterests();
if (current != null) {
l1.addAll(current);
}
}
}
return l1;
}
Aggregations