use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassis method collectSpecificInterests.
@Override
public void collectSpecificInterests(@Nonnull Collection<ItemIdentifier> itemidCollection) {
// if we don't have a pointed inventory we can't be interested in anything
if (getPointedAdjacentOrNoAdjacent().inventories().isEmpty()) {
return;
}
for (int moduleIndex = 0; moduleIndex < getChassisSize(); moduleIndex++) {
LogisticsModule module = getSubModule(moduleIndex);
if (module != null && module.interestedInAttachedInventory()) {
final ISlotUpgradeManager upgradeManager = getUpgradeManager(module.getSlot(), module.getPositionInt());
IInventoryUtil inv = PipeServiceProviderUtilKt.availableSneakyInventories(this, upgradeManager).stream().findFirst().orElse(null);
if (inv == null) {
continue;
}
Set<ItemIdentifier> items = inv.getItems();
itemidCollection.addAll(items);
// also add tag-less variants ... we should probably add a module.interestedIgnoringNBT at some point
items.stream().map(ItemIdentifier::getIgnoringNBT).forEach(itemidCollection::add);
boolean modulesInterestedInUndamged = false;
for (int i = 0; i < getChassisSize(); i++) {
if (getSubModule(moduleIndex).interestedInUndamagedID()) {
modulesInterestedInUndamged = true;
break;
}
}
if (modulesInterestedInUndamged) {
items.stream().map(ItemIdentifier::getUndamaged).forEach(itemidCollection::add);
}
// no need to check other modules for interest in the inventory, when we know that 1 already is.
break;
}
}
for (int i = 0; i < getChassisSize(); i++) {
LogisticsModule module = getSubModule(i);
if (module != null) {
module.collectSpecificInterests(itemidCollection);
}
}
}
use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassis method addToBuffer.
@Override
public int addToBuffer(ItemIdentifierStack item, IAdditionalTargetInformation info) {
if (MainProxy.isServer(getWorld())) {
if (info instanceof ChassiTargetInformation) {
ChassiTargetInformation target = (ChassiTargetInformation) info;
LogisticsModule module = getSubModule(target.moduleSlot);
if (module instanceof IBufferItems) {
return ((IBufferItems) module).addToBuffer(item, info);
}
} else {
if (LogisticsPipes.isDEBUG()) {
System.out.println(item);
new RuntimeException("[AddToBuffer] Information weren't ment for a chassi pipe").printStackTrace();
}
}
}
return item.getStackSize();
}
use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.
the class PipeLogisticsChassis method onAllowedRemoval.
@Override
public void onAllowedRemoval() {
_moduleInventory.removeListener(this);
if (MainProxy.isServer(getWorld())) {
for (int i = 0; i < getChassisSize(); i++) {
LogisticsModule x = 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 stack = ms.makeNormalStack();
ItemModuleInformationManager.saveInformation(stack, getSubModule(i));
_moduleInventory.setInventorySlotContents(i, stack);
}
}
_moduleInventory.dropContents(getWorld(), getX(), getY(), getZ());
for (int i = 0; i < getChassisSize(); i++) {
getModuleUpgradeManager(i).dropUpgrades();
}
}
}
use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.
the class CraftingRecipes method registerResetRecipe.
private void registerResetRecipe(String[] dyes) {
for (ResourceLocation moduleResource : LPItems.modules.values()) {
final Item item = Item.REGISTRY.getObject(moduleResource);
if (item instanceof ItemModule) {
LogisticsModule module = ((ItemModule) item).getModuleForItem(new ItemStack(item), null, null, null);
if (module == null)
continue;
NBTTagCompound tag = new NBTTagCompound();
module.writeToNBT(tag);
if (!tag.hasNoTags()) {
RecipeManager.craftingManager.addShapelessResetRecipe(item, 0);
}
}
}
for (int i = 1; i < 17; i++) {
RecipeManager.craftingManager.addOrdererRecipe(new ItemStack(LPItems.remoteOrderer, 1, i), dyes[i - 1], new ItemStack(LPItems.remoteOrderer, 1, -1));
RecipeManager.craftingManager.addShapelessResetRecipe(LPItems.remoteOrderer, i);
}
RecipeManager.craftingManager.addShapelessResetRecipe(LPItems.remoteOrderer, 0);
}
Aggregations