int idFound = -1;
for(Coord4D obj : structureFound.locations)
{
TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(pointer.getWorldObj());
if(tileEntity.inventoryID != -1)
{
idFound = tileEntity.inventoryID;
break;
}
}
DynamicTankCache cache = new DynamicTankCache();
if(idFound != -1)
{
if(Mekanism.dynamicInventories.get(idFound) != null)
{
cache = MekanismUtils.pullInventory(pointer.getWorldObj(), idFound);
}
}
else {
idFound = MekanismUtils.getUniqueInventoryID();
}
cache.apply(structureFound);
if(structureFound.fluidStored != null)
{
structureFound.fluidStored.amount = Math.min(structureFound.fluidStored.amount, structureFound.volume*FLUID_PER_TANK);
}
for(Coord4D obj : structureFound.locations)
{
TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(pointer.getWorldObj());
tileEntity.inventoryID = idFound;
tileEntity.structure = structureFound;
tileEntity.cachedData.sync(structureFound);