use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method itemArrived.
@Override
public void itemArrived(ItemIdentifierStack item, IAdditionalTargetInformation info) {
if (MainProxy.isServer(getWorld())) {
if (info instanceof ChassiTargetInformation) {
ChassiTargetInformation target = (ChassiTargetInformation) info;
LogisticsModule module = _module.getSubModule(target.moduleSlot);
if (module instanceof IRequireReliableTransport) {
((IRequireReliableTransport) module).itemArrived(item, info);
}
} else {
if (LPConstants.DEBUG && info != null) {
System.out.println(item);
new RuntimeException("[ItemArrived] Information weren't ment for a chassi pipe").printStackTrace();
}
}
}
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method onAllowedRemoval.
@Override
public void onAllowedRemoval() {
_moduleInventory.removeListener(this);
if (MainProxy.isServer(getWorld())) {
for (int i = 0; i < getChassiSize(); i++) {
LogisticsModule x = _module.getSubModule(i);
if (x instanceof ILegacyActiveModule) {
ILegacyActiveModule y = (ILegacyActiveModule) x;
y.onBlockRemoval();
}
}
for (int i = 0; i < _moduleInventory.getSizeInventory(); i++) {
ItemIdentifierStack ms = _moduleInventory.getIDStackInSlot(i);
if (ms != null) {
ItemStack s = ms.makeNormalStack();
ItemModuleInformationManager.saveInfotmation(s, getLogisticsModule().getSubModule(i));
_moduleInventory.setInventorySlotContents(i, s);
}
}
_moduleInventory.dropContents(getWorld(), getX(), getY(), getZ());
}
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method canProvide.
/*** IProvideItems ***/
@Override
public void canProvide(RequestTreeNode tree, RequestTree root, List<IFilter> filters) {
if (!isEnabled()) {
return;
}
for (IFilter filter : filters) {
if (filter.isBlocked() == filter.isFilteredItem(tree.getRequestType()) || filter.blockProvider()) {
return;
}
}
for (int i = 0; i < getChassiSize(); i++) {
LogisticsModule x = _module.getSubModule(i);
if (x instanceof ILegacyActiveModule) {
ILegacyActiveModule y = (ILegacyActiveModule) x;
y.canProvide(tree, root, filters);
}
}
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method getAllItems.
@Override
public void getAllItems(Map<ItemIdentifier, Integer> list, List<IFilter> filter) {
if (!isEnabled()) {
return;
}
for (int i = 0; i < getChassiSize(); i++) {
LogisticsModule x = _module.getSubModule(i);
if (x instanceof ILegacyActiveModule) {
ILegacyActiveModule y = (ILegacyActiveModule) x;
y.getAllItems(list, filter);
}
}
}
use of logisticspipes.modules.abstractmodules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method InventoryChanged.
@Override
public void InventoryChanged(IInventory inventory) {
boolean reInitGui = false;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null) {
if (_module.hasModule(i)) {
_module.removeModule(i);
reInitGui = true;
}
continue;
}
if (stack.getItem() instanceof ItemModule) {
LogisticsModule current = _module.getModule(i);
LogisticsModule next = ((ItemModule) stack.getItem()).getModuleForItem(stack, _module.getModule(i), this, this);
next.registerPosition(ModulePositionType.SLOT, i);
next.registerCCEventQueuer(this);
if (current != next) {
_module.installModule(i, next);
if (!MainProxy.isClient()) {
ItemModuleInformationManager.readInformation(stack, next);
}
ItemModuleInformationManager.removeInformation(stack);
}
inventory.setInventorySlotContents(i, stack);
}
}
if (reInitGui) {
if (MainProxy.isClient(getWorld())) {
if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiChassiPipe) {
FMLClientHandler.instance().getClient().currentScreen.initGui();
}
}
}
if (MainProxy.isServer()) {
if (!localModeWatchers.isEmpty()) {
MainProxy.sendToPlayerList(PacketHandler.getPacket(ChassiePipeModuleContent.class).setIdentList(ItemIdentifierStack.getListFromInventory(_moduleInventory)).setPosX(getX()).setPosY(getY()).setPosZ(getZ()), localModeWatchers);
}
}
}
Aggregations